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 : : #include "scitems.hxx"
30 : : #include <editeng/boxitem.hxx>
31 : : #include <svl/poolcach.hxx>
32 : : #include <unotools/charclass.hxx>
33 : : #include <math.h>
34 : : #include <svl/PasswordHelper.hxx>
35 : : #include <unotools/transliterationwrapper.hxx>
36 : :
37 : : #include "table.hxx"
38 : : #include "patattr.hxx"
39 : : #include "docpool.hxx"
40 : : #include "cell.hxx"
41 : : #include "document.hxx"
42 : : #include "drwlayer.hxx"
43 : : #include "olinetab.hxx"
44 : : #include "rechead.hxx"
45 : : #include "stlpool.hxx"
46 : : #include "attarray.hxx" // Iterator
47 : : #include "markdata.hxx"
48 : : #include "progress.hxx"
49 : : #include "dociter.hxx"
50 : : #include "conditio.hxx"
51 : : #include "chartlis.hxx"
52 : : #include "fillinfo.hxx"
53 : : #include "bcaslot.hxx"
54 : : #include "postit.hxx"
55 : : #include "sheetevents.hxx"
56 : : #include "globstr.hrc"
57 : : #include "segmenttree.hxx"
58 : : #include "queryparam.hxx"
59 : : #include "queryentry.hxx"
60 : : #include "dbdata.hxx"
61 : : #include "colorscale.hxx"
62 : :
63 : : // STATIC DATA -----------------------------------------------------------
64 : :
65 : :
66 : 967 : bool ScTable::SetOutlineTable( const ScOutlineTable* pNewOutline )
67 : : {
68 : 967 : sal_uInt16 nOldSizeX = 0;
69 : 967 : sal_uInt16 nOldSizeY = 0;
70 : 967 : sal_uInt16 nNewSizeX = 0;
71 : 967 : sal_uInt16 nNewSizeY = 0;
72 : :
73 [ + + ]: 967 : if (pOutlineTable)
74 : : {
75 : 6 : nOldSizeX = pOutlineTable->GetColArray()->GetDepth();
76 : 6 : nOldSizeY = pOutlineTable->GetRowArray()->GetDepth();
77 [ + - ]: 6 : delete pOutlineTable;
78 : : }
79 : :
80 [ + + ]: 967 : if (pNewOutline)
81 : : {
82 [ + - ]: 378 : pOutlineTable = new ScOutlineTable( *pNewOutline );
83 : 378 : nNewSizeX = pOutlineTable->GetColArray()->GetDepth();
84 : 378 : nNewSizeY = pOutlineTable->GetRowArray()->GetDepth();
85 : : }
86 : : else
87 : 589 : pOutlineTable = NULL;
88 : :
89 [ + - ][ + + ]: 967 : return ( nNewSizeX != nOldSizeX || nNewSizeY != nOldSizeY ); // Groesse geaendert ?
90 : : }
91 : :
92 : :
93 : 167 : void ScTable::StartOutlineTable()
94 : : {
95 [ + - ]: 167 : if (!pOutlineTable)
96 [ + - ]: 167 : pOutlineTable = new ScOutlineTable;
97 : 167 : }
98 : :
99 : :
100 : 19 : void ScTable::SetSheetEvents( const ScSheetEvents* pNew )
101 : : {
102 [ - + ]: 19 : delete pSheetEvents;
103 [ - + ]: 19 : if (pNew)
104 [ # # ]: 0 : pSheetEvents = new ScSheetEvents(*pNew);
105 : : else
106 : 19 : pSheetEvents = NULL;
107 : :
108 : 19 : SetCalcNotification( false ); // discard notifications before the events were set
109 : :
110 [ - + ]: 19 : if (IsStreamValid())
111 : 0 : SetStreamValid(false);
112 : 19 : }
113 : :
114 : :
115 : 19 : void ScTable::SetCalcNotification( bool bSet )
116 : : {
117 : 19 : bCalcNotification = bSet;
118 : 19 : }
119 : :
120 : :
121 : 21 : bool ScTable::TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCSIZE nSize ) const
122 : : {
123 : 21 : bool bTest = true;
124 : :
125 [ + - ][ + + ]: 21 : if ( nStartCol==0 && nEndCol==MAXCOL && pOutlineTable )
[ - + ]
126 : 0 : bTest = pOutlineTable->TestInsertRow(nSize);
127 : :
128 [ + + ][ + - ]: 18756 : for (SCCOL i=nStartCol; (i<=nEndCol) && bTest; i++)
[ + + ]
129 : 18735 : bTest = aCol[i].TestInsertRow( nSize );
130 : :
131 : 21 : return bTest;
132 : : }
133 : :
134 : :
135 : 21 : void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize )
136 : : {
137 [ + - ]: 21 : IncRecalcLevel();
138 [ + - ]: 21 : InitializeNoteCaptions();
139 [ + - ][ + + ]: 21 : if (nStartCol==0 && nEndCol==MAXCOL)
140 : : {
141 [ + - ][ + - ]: 18 : if (mpRowHeights && pRowFlags)
[ + - ]
142 : : {
143 [ + - ]: 18 : mpRowHeights->insertSegment(nStartRow, nSize, false);
144 [ + - ]: 18 : sal_uInt8 nNewFlags = pRowFlags->Insert( nStartRow, nSize);
145 : : // only copy manual size flag, clear all others
146 [ - + ][ # # ]: 18 : if (nNewFlags && (nNewFlags != CR_MANUALSIZE))
147 : : pRowFlags->SetValue( nStartRow, nStartRow + nSize - 1,
148 [ # # ]: 0 : nNewFlags & CR_MANUALSIZE);
149 : : }
150 : :
151 [ - + ]: 18 : if (pOutlineTable)
152 [ # # ]: 0 : pOutlineTable->InsertRow( nStartRow, nSize );
153 : :
154 [ + - ]: 18 : mpFilteredRows->insertSegment(nStartRow, nSize, true);
155 [ + - ]: 18 : mpHiddenRows->insertSegment(nStartRow, nSize, true);
156 : :
157 [ - + ]: 18 : if (!maRowManualBreaks.empty())
158 : : {
159 : : // Copy all breaks up to nStartRow (non-inclusive).
160 [ # # ]: 0 : ::std::set<SCROW>::iterator itr1 = maRowManualBreaks.lower_bound(nStartRow);
161 [ # # ]: 0 : ::std::set<SCROW> aNewBreaks(maRowManualBreaks.begin(), itr1);
162 : :
163 : : // Copy all breaks from nStartRow (inclusive) to the last element,
164 : : // but add nSize to each value.
165 : 0 : ::std::set<SCROW>::iterator itr2 = maRowManualBreaks.end();
166 [ # # ][ # # ]: 0 : for (; itr1 != itr2; ++itr1)
[ # # ]
167 [ # # ][ # # ]: 0 : aNewBreaks.insert(static_cast<SCROW>(*itr1 + nSize));
168 : :
169 [ # # ]: 0 : maRowManualBreaks.swap(aNewBreaks);
170 : : }
171 : : }
172 : :
173 [ + + ]: 18756 : for (SCCOL j=nStartCol; j<=nEndCol; j++)
174 [ + - ]: 18735 : aCol[j].InsertRow( nStartRow, nSize );
175 : :
176 [ + - ]: 21 : ScNotes aNotes(pDocument);
177 [ + - ]: 21 : ScNotes::iterator itr = maNotes.begin();
178 [ + - ][ + - ]: 24 : while( itr != maNotes.end() )
[ + + ]
179 : : {
180 [ + - ]: 3 : SCCOL nCol = itr->first.first;
181 [ + - ]: 3 : SCROW nRow = itr->first.second;
182 [ + - ]: 3 : ScPostIt* pPostIt = itr->second;
183 [ + - ]: 3 : ++itr;
184 : :
185 [ + - ]: 3 : if (nRow >= nStartRow)
186 : : {
187 [ + - ]: 3 : aNotes.insert(nCol, nRow + nSize, pPostIt);
188 [ + - ]: 3 : maNotes.ReleaseNote(nCol, nRow);
189 : : }
190 : : }
191 : :
192 [ + - ]: 21 : itr = aNotes.begin();
193 [ + - ][ + - ]: 24 : while( itr != aNotes.end() )
[ + + ]
194 : : {
195 [ + - ]: 3 : SCCOL nCol = itr->first.first;
196 [ + - ]: 3 : SCROW nRow = itr->first.second;
197 [ + - ]: 3 : ScPostIt* pPostIt = itr->second;
198 [ + - ]: 3 : ++itr;
199 : :
200 [ + - ]: 3 : maNotes.insert( nCol, nRow, pPostIt);
201 [ + - ]: 3 : aNotes.ReleaseNote( nCol, nRow);
202 : : }
203 : :
204 [ + - ]: 21 : DecRecalcLevel( false );
205 : :
206 : 21 : InvalidatePageBreaks();
207 : :
208 [ - + ]: 21 : if (IsStreamValid())
209 : : // TODO: In the future we may want to check if the table has been
210 : : // really modified before setting the stream invalid.
211 [ # # ][ + - ]: 21 : SetStreamValid(false);
212 : 21 : }
213 : :
214 : :
215 : 10 : void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
216 : : bool* pUndoOutline )
217 : : {
218 [ + - ]: 10 : IncRecalcLevel();
219 [ + - ]: 10 : InitializeNoteCaptions();
220 [ + - ][ + - ]: 10 : if (nStartCol==0 && nEndCol==MAXCOL)
221 : : {
222 [ + - ]: 10 : if (pRowFlags)
223 [ + - ]: 10 : pRowFlags->Remove( nStartRow, nSize);
224 : :
225 [ + - ]: 10 : if (mpRowHeights)
226 [ + - ]: 10 : mpRowHeights->removeSegment(nStartRow, nStartRow+nSize);
227 : :
228 [ + + ]: 10 : if (pOutlineTable)
229 [ + - ][ - + ]: 3 : if (pOutlineTable->DeleteRow( nStartRow, nSize ))
230 [ # # ]: 0 : if (pUndoOutline)
231 : 0 : *pUndoOutline = true;
232 : :
233 [ + - ]: 10 : mpFilteredRows->removeSegment(nStartRow, nStartRow+nSize);
234 [ + - ]: 10 : mpHiddenRows->removeSegment(nStartRow, nStartRow+nSize);
235 : :
236 [ - + ]: 10 : if (!maRowManualBreaks.empty())
237 : : {
238 : : // Erase all manual breaks between nStartRow and nStartRow + nSize - 1 (inclusive).
239 [ # # ]: 0 : std::set<SCROW>::iterator itr1 = maRowManualBreaks.lower_bound(nStartRow);
240 [ # # ]: 0 : std::set<SCROW>::iterator itr2 = maRowManualBreaks.upper_bound(static_cast<SCROW>(nStartRow + nSize - 1));
241 [ # # ]: 0 : maRowManualBreaks.erase(itr1, itr2);
242 : :
243 : : // Copy all breaks from the 1st element up to nStartRow to the new container.
244 [ # # ]: 0 : itr1 = maRowManualBreaks.lower_bound(nStartRow);
245 [ # # ]: 0 : ::std::set<SCROW> aNewBreaks(maRowManualBreaks.begin(), itr1);
246 : :
247 : : // Copy all breaks from nStartRow to the last element, but subtract each value by nSize.
248 : 0 : itr2 = maRowManualBreaks.end();
249 [ # # ][ # # ]: 0 : for (; itr1 != itr2; ++itr1)
[ # # ]
250 [ # # ][ # # ]: 0 : aNewBreaks.insert(static_cast<SCROW>(*itr1 - nSize));
251 : :
252 [ # # ]: 0 : maRowManualBreaks.swap(aNewBreaks);
253 : : }
254 : : }
255 : :
256 [ + - ]: 10 : ScNotes aNotes(pDocument);
257 [ + - ]: 10 : ScNotes::iterator itr = maNotes.begin();
258 [ + - ][ + - ]: 10 : while( itr != maNotes.end() )
[ - + ]
259 : : {
260 [ # # ]: 0 : SCCOL nCol = itr->first.first;
261 [ # # ]: 0 : SCROW nRow = itr->first.second;
262 [ # # ]: 0 : ScPostIt* pPostIt = itr->second;
263 [ # # ]: 0 : ++itr;
264 : :
265 [ # # ]: 0 : if (nRow >= nStartRow)
266 : : {
267 [ # # ]: 0 : aNotes.insert(nCol, nRow - nSize, pPostIt);
268 [ # # ]: 0 : maNotes.ReleaseNote(nCol, nRow);
269 : : }
270 : : }
271 : :
272 [ + - ]: 10 : itr = aNotes.begin();
273 [ + - ][ + - ]: 10 : while( itr != aNotes.end() )
[ - + ]
274 : : {
275 [ # # ]: 0 : SCCOL nCol = itr->first.first;
276 [ # # ]: 0 : SCROW nRow = itr->first.second;
277 [ # # ]: 0 : ScPostIt* pPostIt = itr->second;
278 [ # # ]: 0 : ++itr;
279 : :
280 [ # # ]: 0 : maNotes.insert( nCol, nRow, pPostIt);
281 [ # # ]: 0 : aNotes.ReleaseNote( nCol, nRow);
282 : : }
283 : :
284 : : { // scope for bulk broadcast
285 [ + - ]: 10 : ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM());
286 [ + + ]: 10250 : for (SCCOL j=nStartCol; j<=nEndCol; j++)
287 [ + - ][ + - ]: 10250 : aCol[j].DeleteRow( nStartRow, nSize );
288 : : }
289 [ + - ]: 10 : DecRecalcLevel();
290 : :
291 : 10 : InvalidatePageBreaks();
292 : :
293 [ - + ]: 10 : if (IsStreamValid())
294 : : // TODO: In the future we may want to check if the table has been
295 : : // really modified before setting the stream invalid.
296 [ # # ][ + - ]: 10 : SetStreamValid(false);
297 : 10 : }
298 : :
299 : :
300 : 6 : bool ScTable::TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const
301 : : {
302 : 6 : bool bTest = true;
303 : :
304 [ + - ][ + + ]: 6 : if ( nStartRow==0 && nEndRow==MAXROW && pOutlineTable )
[ - + ]
305 : 0 : bTest = pOutlineTable->TestInsertCol(nSize);
306 : :
307 [ - + ]: 6 : if ( nSize > static_cast<SCSIZE>(MAXCOL) )
308 : 0 : bTest = false;
309 : :
310 [ + + ][ + - ]: 13 : for (SCCOL i=MAXCOL; (i+static_cast<SCCOL>(nSize)>MAXCOL) && bTest; i--)
[ + + ]
311 : 7 : bTest = aCol[i].TestInsertCol(nStartRow, nEndRow);
312 : :
313 : 6 : return bTest;
314 : : }
315 : :
316 : :
317 : 6 : void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize )
318 : : {
319 [ + - ]: 6 : IncRecalcLevel();
320 [ + - ]: 6 : InitializeNoteCaptions();
321 [ + - ][ + + ]: 6 : if (nStartRow==0 && nEndRow==MAXROW)
322 : : {
323 [ + - ][ + - ]: 3 : if (pColWidth && pColFlags)
324 : : {
325 : 3 : memmove( &pColWidth[nStartCol+nSize], &pColWidth[nStartCol],
326 : 6 : (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColWidth[0]) );
327 : 3 : memmove( &pColFlags[nStartCol+nSize], &pColFlags[nStartCol],
328 : 3 : (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColFlags[0]) );
329 : : }
330 [ - + ]: 3 : if (pOutlineTable)
331 [ # # ]: 0 : pOutlineTable->InsertCol( nStartCol, nSize );
332 : :
333 [ + - ]: 3 : mpHiddenCols->insertSegment(nStartCol, static_cast<SCCOL>(nSize), true);
334 [ + - ]: 3 : mpFilteredCols->insertSegment(nStartCol, static_cast<SCCOL>(nSize), true);
335 : :
336 [ - + ]: 3 : if (!maColManualBreaks.empty())
337 : : {
338 : 0 : std::set<SCCOL>::reverse_iterator rit = maColManualBreaks.rbegin();
339 [ # # ][ # # ]: 0 : while (rit != maColManualBreaks.rend())
340 : : {
341 [ # # ]: 0 : SCCOL nCol = *rit;
342 [ # # ]: 0 : if (nCol < nStartCol)
343 : 0 : break; // while
344 : : else
345 : : {
346 [ # # ][ # # ]: 0 : maColManualBreaks.erase( (++rit).base());
[ # # ]
347 [ # # ]: 0 : maColManualBreaks.insert( static_cast<SCCOL>( nCol + nSize));
348 : : }
349 : : }
350 : : }
351 : : }
352 : :
353 : :
354 [ + - ][ + + ]: 6 : if ((nStartRow == 0) && (nEndRow == MAXROW))
355 : : {
356 [ + + ]: 7 : for (SCSIZE i=0; i < nSize; i++)
357 [ + + ]: 4095 : for (SCCOL nCol = MAXCOL; nCol > nStartCol; nCol--)
358 [ + - ]: 4094 : aCol[nCol].SwapCol(aCol[nCol-1]);
359 : : }
360 : : else
361 : : {
362 [ + + ]: 3069 : for (SCSIZE i=0; static_cast<SCCOL>(i+nSize)+nStartCol <= MAXCOL; i++)
363 [ + - ]: 3066 : aCol[MAXCOL - nSize - i].MoveTo(nStartRow, nEndRow, aCol[MAXCOL - i]);
364 : : }
365 : :
366 [ + - ]: 6 : ScNotes aNotes(pDocument);
367 [ + - ]: 6 : ScNotes::iterator itr = maNotes.begin();
368 [ + - ][ + - ]: 9 : while( itr != maNotes.end() )
[ + + ]
369 : : {
370 [ + - ]: 3 : SCCOL nCol = itr->first.first;
371 [ + - ]: 3 : SCROW nRow = itr->first.second;
372 [ + - ]: 3 : ScPostIt* pPostIt = itr->second;
373 [ + - ]: 3 : ++itr;
374 : :
375 [ + - ]: 3 : if (nCol >= nStartCol)
376 : : {
377 [ + - ]: 3 : aNotes.insert(nCol + nSize, nRow, pPostIt);
378 [ + - ]: 3 : maNotes.ReleaseNote(nCol, nRow);
379 : : }
380 : : }
381 : :
382 [ + - ]: 6 : itr = aNotes.begin();
383 [ + - ][ + - ]: 9 : while( itr != aNotes.end() )
[ + + ]
384 : : {
385 [ + - ]: 3 : SCCOL nCol = itr->first.first;
386 [ + - ]: 3 : SCROW nRow = itr->first.second;
387 [ + - ]: 3 : ScPostIt* pPostIt = itr->second;
388 [ + - ]: 3 : ++itr;
389 : :
390 [ + - ]: 3 : maNotes.insert( nCol, nRow, pPostIt);
391 [ + - ]: 3 : aNotes.ReleaseNote( nCol, nRow);
392 : : }
393 : :
394 [ + + ]: 6 : if (nStartCol>0) // copy old attributes
395 : : {
396 : : sal_uInt16 nWhichArray[2];
397 : 4 : nWhichArray[0] = ATTR_MERGE;
398 : 4 : nWhichArray[1] = 0;
399 : :
400 [ + + ]: 8 : for (SCSIZE i=0; i<nSize; i++)
401 : : {
402 : 4 : aCol[nStartCol-1].CopyToColumn( nStartRow, nEndRow, IDF_ATTRIB,
403 [ + - ]: 4 : false, aCol[nStartCol+i] );
404 : 4 : aCol[nStartCol+i].RemoveFlags( nStartRow, nEndRow,
405 [ + - ]: 4 : SC_MF_HOR | SC_MF_VER | SC_MF_AUTO );
406 [ + - ]: 4 : aCol[nStartCol+i].ClearItems( nStartRow, nEndRow, nWhichArray );
407 : : }
408 : : }
409 [ + - ]: 6 : DecRecalcLevel();
410 : :
411 : 6 : InvalidatePageBreaks();
412 : :
413 [ - + ]: 6 : if (IsStreamValid())
414 : : // TODO: In the future we may want to check if the table has been
415 : : // really modified before setting the stream invalid.
416 [ # # ][ + - ]: 6 : SetStreamValid(false);
417 : 6 : }
418 : :
419 : :
420 : 3 : void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize,
421 : : bool* pUndoOutline )
422 : : {
423 [ + - ]: 3 : IncRecalcLevel();
424 [ + - ]: 3 : InitializeNoteCaptions();
425 [ + - ][ + - ]: 3 : if (nStartRow==0 && nEndRow==MAXROW)
426 : : {
427 [ + - ][ + - ]: 3 : if (pColWidth && pColFlags)
428 : : {
429 : 3 : memmove( &pColWidth[nStartCol], &pColWidth[nStartCol+nSize],
430 : 6 : (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColWidth[0]) );
431 : 3 : memmove( &pColFlags[nStartCol], &pColFlags[nStartCol+nSize],
432 : 3 : (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColFlags[0]) );
433 : : }
434 [ - + ]: 3 : if (pOutlineTable)
435 [ # # ][ # # ]: 0 : if (pOutlineTable->DeleteCol( nStartCol, nSize ))
436 [ # # ]: 0 : if (pUndoOutline)
437 : 0 : *pUndoOutline = true;
438 : :
439 : 3 : SCCOL nRmSize = nStartCol + static_cast<SCCOL>(nSize);
440 [ + - ]: 3 : mpHiddenCols->removeSegment(nStartCol, nRmSize);
441 [ + - ]: 3 : mpFilteredCols->removeSegment(nStartCol, nRmSize);
442 : :
443 [ - + ]: 3 : if (!maColManualBreaks.empty())
444 : : {
445 [ # # ]: 0 : std::set<SCCOL>::iterator it = maColManualBreaks.upper_bound( static_cast<SCCOL>( nStartCol + nSize - 1));
446 [ # # ][ # # ]: 0 : maColManualBreaks.erase( maColManualBreaks.lower_bound( nStartCol), it);
447 [ # # ][ # # ]: 0 : while (it != maColManualBreaks.end())
448 : : {
449 [ # # ]: 0 : SCCOL nCol = *it;
450 [ # # ][ # # ]: 0 : maColManualBreaks.erase( it++);
451 [ # # ]: 0 : maColManualBreaks.insert( static_cast<SCCOL>( nCol - nSize));
452 : : }
453 : : }
454 : : }
455 : :
456 : :
457 : : { // scope for bulk broadcast
458 [ + - ]: 3 : ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM());
459 [ + + ]: 7 : for (SCSIZE i = 0; i < nSize; i++)
460 [ + - ][ + - ]: 7 : aCol[nStartCol + i].DeleteArea(nStartRow, nEndRow, IDF_ALL);
461 : : }
462 : :
463 [ + - ][ + - ]: 3 : if ((nStartRow == 0) && (nEndRow == MAXROW))
464 : : {
465 [ + + ]: 7 : for (SCSIZE i=0; i < nSize; i++)
466 [ + + ]: 4095 : for (SCCOL nCol = nStartCol; nCol < MAXCOL; nCol++)
467 [ + - ]: 4094 : aCol[nCol].SwapCol(aCol[nCol+1]);
468 : : }
469 : : else
470 : : {
471 [ # # ]: 0 : for (SCSIZE i=0; static_cast<SCCOL>(i+nSize)+nStartCol <= MAXCOL; i++)
472 [ # # ]: 0 : aCol[nStartCol + nSize + i].MoveTo(nStartRow, nEndRow, aCol[nStartCol + i]);
473 : : }
474 : :
475 [ + - ]: 3 : ScNotes aNotes(pDocument);
476 [ + - ]: 3 : ScNotes::iterator itr = maNotes.begin();
477 [ + - ][ + - ]: 3 : while( itr != maNotes.end() )
[ - + ]
478 : : {
479 [ # # ]: 0 : SCCOL nCol = itr->first.first;
480 [ # # ]: 0 : SCROW nRow = itr->first.second;
481 [ # # ]: 0 : ScPostIt* pPostIt = itr->second;
482 [ # # ]: 0 : ++itr;
483 : :
484 [ # # ]: 0 : if (nCol >= nStartCol)
485 : : {
486 [ # # ]: 0 : aNotes.insert(nCol - nSize, nRow, pPostIt);
487 [ # # ]: 0 : maNotes.ReleaseNote(nCol, nRow);
488 : : }
489 : : }
490 : :
491 [ + - ]: 3 : itr = aNotes.begin();
492 [ + - ][ + - ]: 3 : while( itr != aNotes.end() )
[ - + ]
493 : : {
494 [ # # ]: 0 : SCCOL nCol = itr->first.first;
495 [ # # ]: 0 : SCROW nRow = itr->first.second;
496 [ # # ]: 0 : ScPostIt* pPostIt = itr->second;
497 [ # # ]: 0 : ++itr;
498 : :
499 [ # # ]: 0 : maNotes.insert( nCol, nRow, pPostIt);
500 [ # # ]: 0 : aNotes.ReleaseNote( nCol, nRow);
501 : : }
502 : :
503 [ + - ]: 3 : DecRecalcLevel();
504 : :
505 : 3 : InvalidatePageBreaks();
506 : :
507 [ - + ]: 3 : if (IsStreamValid())
508 : : // TODO: In the future we may want to check if the table has been
509 : : // really modified before setting the stream invalid.
510 [ # # ][ + - ]: 3 : SetStreamValid(false);
511 : 3 : }
512 : :
513 : :
514 : 583 : void ScTable::DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal_uInt16 nDelFlag)
515 : : {
516 [ - + ]: 583 : if (nCol2 > MAXCOL) nCol2 = MAXCOL;
517 [ - + ]: 583 : if (nRow2 > MAXROW) nRow2 = MAXROW;
518 [ + - ][ + - ]: 583 : if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
[ + - ]
519 : : {
520 : : { // scope for bulk broadcast
521 [ + - ]: 583 : ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM());
522 [ + + ]: 11948 : for (SCCOL i = nCol1; i <= nCol2; i++)
523 [ + - ][ + - ]: 11948 : aCol[i].DeleteArea(nRow1, nRow2, nDelFlag);
524 : : }
525 : :
526 : : //
527 : : // Zellschutz auf geschuetzter Tabelle nicht setzen
528 : : //
529 : :
530 [ - + ][ # # ]: 583 : if ( IsProtected() && (nDelFlag & IDF_ATTRIB) )
[ - + ]
531 : : {
532 [ # # ][ # # ]: 0 : ScPatternAttr aPattern(pDocument->GetPool());
533 [ # # ][ # # ]: 0 : aPattern.GetItemSet().Put( ScProtectionAttr( false ) );
[ # # ]
534 [ # # ][ # # ]: 0 : ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern );
535 : : }
536 : : }
537 : :
538 [ + + ]: 583 : if (nDelFlag & IDF_NOTE)
539 : 537 : maNotes.erase( nCol1, nRow1, nCol2, nRow2, true );
540 : :
541 [ - + ]: 583 : if (IsStreamValid())
542 : : // TODO: In the future we may want to check if the table has been
543 : : // really modified before setting the stream invalid.
544 : 0 : SetStreamValid(false);
545 : 583 : }
546 : :
547 : :
548 : 14 : void ScTable::DeleteSelection( sal_uInt16 nDelFlag, const ScMarkData& rMark )
549 : : {
550 : : { // scope for bulk broadcast
551 [ + - ]: 14 : ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM());
552 [ + + ]: 14350 : for (SCCOL i=0; i<=MAXCOL; i++)
553 [ + - ][ + - ]: 14350 : aCol[i].DeleteSelection( nDelFlag, rMark );
554 : : }
555 : :
556 [ + - ]: 14 : ScRangeList aRangeList;
557 [ + - ]: 14 : rMark.FillRangeListWithMarks(&aRangeList, false);
558 : :
559 [ + - ][ + + ]: 31 : for (size_t i = 0; i < aRangeList.size(); ++i)
560 : : {
561 [ + - ]: 17 : ScRange* pRange = aRangeList[i];
562 [ + + ][ + - ]: 17 : if (nDelFlag & IDF_NOTE && pRange)
563 [ + - ]: 9 : maNotes.erase(pRange->aStart.Col(), pRange->aStart.Row(), pRange->aEnd.Col(), pRange->aEnd.Row(), true);
564 : : }
565 : :
566 : : //
567 : : // Zellschutz auf geschuetzter Tabelle nicht setzen
568 : : //
569 : :
570 [ + - ][ - + ]: 14 : if ( IsProtected() && (nDelFlag & IDF_ATTRIB) )
[ # # ][ - + ]
571 : : {
572 [ # # ]: 0 : ScDocumentPool* pPool = pDocument->GetPool();
573 [ # # ]: 0 : SfxItemSet aSet( *pPool, ATTR_PATTERN_START, ATTR_PATTERN_END );
574 [ # # ][ # # ]: 0 : aSet.Put( ScProtectionAttr( false ) );
[ # # ]
575 [ # # ]: 0 : SfxItemPoolCache aCache( pPool, &aSet );
576 [ # # ][ # # ]: 0 : ApplySelectionCache( &aCache, rMark );
[ # # ]
577 : : }
578 : :
579 [ - + ]: 14 : if (IsStreamValid())
580 : : // TODO: In the future we may want to check if the table has been
581 : : // really modified before setting the stream invalid.
582 [ # # ][ + - ]: 14 : SetStreamValid(false);
583 : 14 : }
584 : :
585 : :
586 : : // pTable = Clipboard
587 : 12 : void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
588 : : ScTable* pTable, bool bKeepScenarioFlags, bool bCloneNoteCaptions)
589 : : {
590 [ + - ][ + - ]: 12 : if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
[ + - ]
591 : : {
592 : : // copy content
593 : : //local range names need to be copied first for formula cells
594 [ + - ][ + + ]: 12 : if (!pTable->mpRangeName && mpRangeName)
595 [ + - ]: 3 : pTable->mpRangeName = new ScRangeName(*mpRangeName);
596 : :
597 : : // notes
598 : 12 : pTable->maNotes = *maNotes.clone(pTable->pDocument, nCol1, nRow1, nCol2, nRow2, bCloneNoteCaptions, nTab);
599 : :
600 : : SCCOL i;
601 : :
602 [ + + ]: 33 : for ( i = nCol1; i <= nCol2; i++)
603 : 21 : aCol[i].CopyToClip(nRow1, nRow2, pTable->aCol[i], bKeepScenarioFlags);
604 : :
605 : : // copy widths/heights, and only "hidden", "filtered" and "manual" flags
606 : : // also for all preceding columns/rows, to have valid positions for drawing objects
607 : :
608 [ + - ][ + - ]: 12 : if (pColWidth && pTable->pColWidth)
609 [ + + ]: 33 : for (i=0; i<=nCol2; i++)
610 : 21 : pTable->pColWidth[i] = pColWidth[i];
611 : :
612 : 12 : pTable->CopyColHidden(*this, 0, nCol2);
613 : 12 : pTable->CopyColFiltered(*this, 0, nCol2);
614 [ - + ]: 12 : if (pDBDataNoName)
615 [ # # ]: 0 : pTable->SetAnonymousDBData(new ScDBData(*pDBDataNoName));
616 : :
617 : :
618 [ + - ][ + - ]: 12 : if (pRowFlags && pTable->pRowFlags && mpRowHeights && pTable->mpRowHeights)
[ + - ][ + - ]
[ + - ]
619 : : {
620 : 12 : pTable->pRowFlags->CopyFromAnded( *pRowFlags, 0, nRow2, CR_MANUALSIZE);
621 : 12 : pTable->CopyRowHeight(*this, 0, nRow2, 0);
622 : : }
623 : :
624 : 12 : pTable->CopyRowHidden(*this, 0, nRow2);
625 : 12 : pTable->CopyRowFiltered(*this, 0, nRow2);
626 : :
627 : : // ggf. Formeln durch Werte ersetzen
628 : :
629 [ - + ]: 12 : if ( IsProtected() )
630 [ # # ]: 0 : for (i = nCol1; i <= nCol2; i++)
631 : 0 : pTable->aCol[i].RemoveProtected(nRow1, nRow2);
632 : :
633 [ + - ]: 12 : pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->pDocument, *mpCondFormatList));
634 : : }
635 : 12 : }
636 : :
637 : 12 : void ScTable::CopyToClip(const ScRangeList& rRanges, ScTable* pTable,
638 : : bool bKeepScenarioFlags, bool bCloneNoteCaptions)
639 : : {
640 [ + - ]: 12 : ScRangeList aRanges(rRanges);
641 [ + - ][ + + ]: 24 : for ( size_t i = 0, nListSize = aRanges.size(); i < nListSize; ++i )
642 : : {
643 [ + - ]: 12 : ScRange* p = aRanges[ i ];
644 : 24 : CopyToClip(p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(),
645 [ + - ]: 36 : pTable, bKeepScenarioFlags, bCloneNoteCaptions);
646 [ + - ]: 12 : }
647 : 12 : }
648 : :
649 : 25 : void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
650 : : SCsCOL nDx, SCsROW nDy, ScTable* pTable)
651 : : {
652 [ + - ]: 25 : std::map<sal_Int32, sal_Int32> aOldIdToNewId;
653 [ + - ]: 25 : std::map<sal_Int32, ScRangeList> aIdToRange;
654 : :
655 : 25 : ScConditionalFormatList* pOldCondFormatList = pTable->mpCondFormatList.get();
656 [ + + ]: 120 : for(SCCOL i = nCol1; i <= nCol2; ++i)
657 : : {
658 [ + - ]: 95 : ScAttrIterator* pIter = pTable->aCol[i-nDx].CreateAttrIterator( nRow1-nDy, nRow2-nDy );
659 : 95 : SCROW nStartRow = 0, nEndRow = 0;
660 [ + - ]: 95 : const ScPatternAttr* pPattern = pIter->Next( nStartRow, nEndRow );
661 [ + - ]: 95 : sal_uInt32 nId = ((SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue();
662 [ - + ]: 95 : if ( nId != 0)
663 : : {
664 [ # # ][ # # ]: 0 : if (aOldIdToNewId.find(nId) == aOldIdToNewId.end())
[ # # ]
665 : : {
666 [ # # ]: 0 : ScConditionalFormat* pFormat = pOldCondFormatList->GetFormat(nId);
667 [ # # ]: 0 : ScConditionalFormat* pNewFormat = pFormat->Clone(pDocument);
668 : 0 : pNewFormat->SetKey(0);
669 : : //not in list => create entries in both maps and new format
670 : 0 : sal_uLong nMax = 0;
671 [ # # ][ # # ]: 0 : for(ScConditionalFormatList::const_iterator itr = mpCondFormatList->begin();
[ # # ][ # # ]
[ # # ]
672 [ # # ]: 0 : itr != mpCondFormatList->end(); ++itr)
673 : : {
674 [ # # ][ # # ]: 0 : if(itr->GetKey() > nMax)
675 [ # # ]: 0 : nMax = itr->GetKey();
676 : : }
677 : 0 : pNewFormat->SetKey(nMax + 1);
678 [ # # ]: 0 : mpCondFormatList->InsertNew(pNewFormat);
679 : 0 : sal_Int32 nNewId = pNewFormat->GetKey();
680 [ # # ][ # # ]: 0 : aOldIdToNewId.insert( std::pair<sal_Int32, sal_Int32>( nId, nNewId ) );
681 [ # # ][ # # ]: 0 : aIdToRange.insert( std::pair<sal_Int32, ScRangeList>( nId, ScRangeList() ) );
[ # # ][ # # ]
[ # # ]
682 : : }
683 : :
684 [ # # ][ # # ]: 0 : aIdToRange.find(nId)->second.Join( ScRange( i, nStartRow + nDy, nTab, i, nEndRow + nDy, nTab ) );
[ # # ]
685 : : }
686 : : }
687 : :
688 [ + - ][ # # ]: 50 : for(std::map<sal_Int32, ScRangeList>::const_iterator itr = aIdToRange.begin();
[ + - ][ - + ]
689 [ + - ]: 25 : itr != aIdToRange.end(); ++itr)
690 : : {
691 [ # # ][ # # ]: 0 : sal_uInt32 nNewKey = aOldIdToNewId.find(itr->first)->second;
[ # # ]
692 [ # # ]: 0 : ScConditionalFormat* pFormat = mpCondFormatList->GetFormat( nNewKey );
693 [ # # ]: 0 : if(!pFormat)
694 : 0 : continue;
695 : :
696 : : pFormat->UpdateReference(URM_MOVE, ScRange(nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, nRow2 - nDy, pTable->nTab),
697 [ # # ]: 0 : nDx, nDy, pTable->nTab - nTab);
698 [ # # ][ # # ]: 0 : pFormat->AddRange(itr->second);
699 : :
700 [ # # ][ # # ]: 0 : ScPatternAttr aPattern( pDocument->GetPool() );
701 [ # # ][ # # ]: 0 : aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nNewKey ) );
[ # # ]
702 [ # # ]: 0 : ScMarkData aMarkData;
703 [ # # ][ # # ]: 0 : aMarkData.MarkFromRangeList(itr->second, true);
704 [ # # ]: 0 : pDocument->ApplySelectionPattern( aPattern, aMarkData );
705 [ # # ][ # # ]: 25 : }
706 : 25 : }
707 : :
708 : 41 : void ScTable::CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
709 : : SCsCOL nDx, SCsROW nDy, sal_uInt16 nInsFlag,
710 : : bool bAsLink, bool bSkipAttrForEmpty, ScTable* pTable)
711 : : {
712 : :
713 [ - + ]: 41 : if (nCol2 > MAXCOL)
714 : 0 : nCol2 = MAXCOL;
715 [ - + ]: 41 : if (nRow2 > MAXROW)
716 : 0 : nRow2 = MAXROW;
717 : :
718 [ + - ][ + - ]: 41 : if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
[ + - ]
719 : : {
720 : 41 : IncRecalcLevel();
721 [ + + ]: 216 : for ( SCCOL i = nCol1; i <= nCol2; i++)
722 : 175 : aCol[i].CopyFromClip(nRow1, nRow2, nDy, nInsFlag, bAsLink, bSkipAttrForEmpty, pTable->aCol[i - nDx]);
723 : :
724 : : //remove old notes
725 [ + + ]: 41 : if (nInsFlag & IDF_CONTENTS)
726 : 25 : maNotes.erase(nCol1, nRow1, nCol2, nRow2);
727 : :
728 : 41 : bool bAddNotes = nInsFlag & (IDF_NOTE | IDF_ADDNOTES);
729 [ + + ]: 41 : if (bAddNotes)
730 : : {
731 : 22 : bool bCloneCaption = (nInsFlag & IDF_NOCAPTIONS) == 0;
732 : 22 : maNotes.CopyFromClip(pTable->maNotes, pDocument, nCol1, nRow1, nCol2, nRow2, nDx, nDy, nTab, bCloneCaption);
733 : : }
734 : :
735 : :
736 [ + + ]: 41 : if ((nInsFlag & IDF_ATTRIB) != 0)
737 : : {
738 [ + + ][ - + ]: 25 : if (nRow1==0 && nRow2==MAXROW && pColWidth && pTable->pColWidth)
[ # # ][ # # ]
739 [ # # ]: 0 : for (SCCOL i=nCol1; i<=nCol2; i++)
740 : 0 : pColWidth[i] = pTable->pColWidth[i-nDx];
741 : :
742 [ + + ][ - + ]: 25 : if (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pTable->mpRowHeights &&
[ # # ][ # # ]
[ # # ][ # # ]
[ - + ]
743 : : pRowFlags && pTable->pRowFlags)
744 : : {
745 : 0 : CopyRowHeight(*pTable, nRow1, nRow2, -nDy);
746 : : // Must copy CR_MANUALSIZE bit too, otherwise pRowHeight doesn't make sense
747 [ # # ]: 0 : for (SCROW j=nRow1; j<=nRow2; j++)
748 : : {
749 [ # # ]: 0 : if ( pTable->pRowFlags->GetValue(j-nDy) & CR_MANUALSIZE )
750 : 0 : pRowFlags->OrValue( j, CR_MANUALSIZE);
751 : : else
752 [ # # ]: 0 : pRowFlags->AndValue( j, sal::static_int_cast<sal_uInt8>(~CR_MANUALSIZE));
753 : : }
754 : : }
755 : :
756 : : // Zellschutz auf geschuetzter Tabelle nicht setzen
757 [ - + ][ # # ]: 25 : if ( IsProtected() && (nInsFlag & IDF_ATTRIB) )
[ - + ]
758 : : {
759 [ # # ][ # # ]: 0 : ScPatternAttr aPattern(pDocument->GetPool());
760 [ # # ][ # # ]: 0 : aPattern.GetItemSet().Put( ScProtectionAttr( false ) );
[ # # ]
761 [ # # ][ # # ]: 0 : ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern );
762 : : }
763 : :
764 : : // create deep copies for conditional formatting
765 : 25 : CopyConditionalFormat( nCol1, nRow1, nCol2, nRow2, nDx, nDy, pTable);
766 : : }
767 : 41 : DecRecalcLevel();
768 : : }
769 : 41 : }
770 : :
771 : :
772 : 0 : void ScTable::MixData( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
773 : : sal_uInt16 nFunction, bool bSkipEmpty, ScTable* pSrcTab )
774 : : {
775 [ # # ]: 0 : for (SCCOL i=nCol1; i<=nCol2; i++)
776 : 0 : aCol[i].MixData( nRow1, nRow2, nFunction, bSkipEmpty, pSrcTab->aCol[i] );
777 : 0 : }
778 : :
779 : :
780 : : // Markierung von diesem Dokument
781 : 0 : void ScTable::MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction,
782 : : bool bSkipEmpty, ScTable* pSrcTab )
783 : : {
784 [ # # ]: 0 : for (SCCOL i=0; i<=MAXCOL; i++)
785 : 0 : aCol[i].MixMarked( rMark, nFunction, bSkipEmpty, pSrcTab->aCol[i] );
786 : 0 : }
787 : :
788 : :
789 : 0 : void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
790 : : ScTable* pTransClip, sal_uInt16 nFlags, bool bAsLink )
791 : : {
792 : 0 : bool bWasCut = pDocument->IsCutMode();
793 : :
794 : 0 : ScDocument* pDestDoc = pTransClip->pDocument;
795 : :
796 [ # # ]: 0 : for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
797 : : {
798 : : SCROW nRow;
799 : : ScBaseCell* pCell;
800 : :
801 [ # # ][ # # ]: 0 : if ( bAsLink && nFlags == IDF_ALL )
802 : : {
803 : : // with IDF_ALL, also create links (formulas) for empty cells
804 : :
805 [ # # ]: 0 : for ( nRow=nRow1; nRow<=nRow2; nRow++ )
806 : : {
807 : : // create simple formula, as in ScColumn::CreateRefCell
808 : :
809 : 0 : ScAddress aDestPos( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab );
810 : : ScSingleRefData aRef;
811 : 0 : aRef.nCol = nCol;
812 : 0 : aRef.nRow = nRow;
813 : 0 : aRef.nTab = nTab;
814 : 0 : aRef.InitFlags(); // -> all absolute
815 : 0 : aRef.SetFlag3D(true);
816 [ # # ]: 0 : aRef.CalcRelFromAbs( aDestPos );
817 [ # # ]: 0 : ScTokenArray aArr;
818 [ # # ]: 0 : aArr.AddSingleReference( aRef );
819 : :
820 [ # # ][ # # ]: 0 : ScBaseCell* pNew = new ScFormulaCell( pDestDoc, aDestPos, &aArr );
[ # # ]
821 [ # # ]: 0 : pTransClip->PutCell( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), pNew );
822 [ # # ]: 0 : }
823 : : }
824 : : else
825 : : {
826 [ # # ]: 0 : ScColumnIterator aIter( &aCol[nCol], nRow1, nRow2 );
827 [ # # ][ # # ]: 0 : while (aIter.Next( nRow, pCell ))
828 : : {
829 : 0 : ScAddress aDestPos( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab );
830 : : ScBaseCell* pNew;
831 [ # # ]: 0 : if ( bAsLink ) // Referenz erzeugen ?
832 : : {
833 [ # # ][ # # ]: 0 : pNew = aCol[nCol].CreateRefCell( pDestDoc, aDestPos, aIter.GetIndex(), nFlags );
[ # # ]
834 : : }
835 : : else // kopieren
836 : : {
837 : 0 : ScAddress aOwnPos( nCol, nRow, nTab );
838 [ # # ]: 0 : if (pCell->GetCellType() == CELLTYPE_FORMULA)
839 : : {
840 [ # # ]: 0 : pNew = pCell->Clone( *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING );
841 : :
842 : : // Referenzen drehen
843 : : // bei Cut werden Referenzen spaeter per UpdateTranspose angepasst
844 : :
845 [ # # ]: 0 : if (!bWasCut)
846 [ # # ][ # # ]: 0 : ((ScFormulaCell*)pNew)->TransposeReference();
847 : : }
848 : : else
849 : : {
850 [ # # ]: 0 : pNew = pCell->Clone( *pDestDoc, aDestPos );
851 : : }
852 : : }
853 [ # # ]: 0 : pTransClip->PutCell( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), pNew );
854 [ # # ]: 0 : }
855 : : }
856 : :
857 : : // Attribute
858 : :
859 : : SCROW nAttrRow1;
860 : : SCROW nAttrRow2;
861 : : const ScPatternAttr* pPattern;
862 [ # # ]: 0 : ScAttrIterator* pAttrIter = aCol[nCol].CreateAttrIterator( nRow1, nRow2 );
863 [ # # ][ # # ]: 0 : while ( (pPattern = pAttrIter->Next( nAttrRow1, nAttrRow2 )) != 0 )
864 : : {
865 [ # # ]: 0 : if ( !IsDefaultItem( pPattern ) )
866 : : {
867 : 0 : const SfxItemSet& rSet = pPattern->GetItemSet();
868 [ # # ][ # # ]: 0 : if ( rSet.GetItemState( ATTR_MERGE, false ) == SFX_ITEM_DEFAULT &&
[ # # ][ # # ]
[ # # ]
869 [ # # ]: 0 : rSet.GetItemState( ATTR_MERGE_FLAG, false ) == SFX_ITEM_DEFAULT &&
870 [ # # ]: 0 : rSet.GetItemState( ATTR_BORDER, false ) == SFX_ITEM_DEFAULT )
871 : : {
872 : : // no borders or merge items involved - use pattern as-is
873 [ # # ]: 0 : for (nRow = nAttrRow1; nRow<=nAttrRow2; nRow++)
874 [ # # ]: 0 : pTransClip->SetPattern( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), *pPattern, true );
875 : : }
876 : : else
877 : : {
878 : : // transpose borders and merge values, remove merge flags (refreshed after pasting)
879 [ # # ]: 0 : ScPatternAttr aNewPattern( *pPattern );
880 : 0 : SfxItemSet& rNewSet = aNewPattern.GetItemSet();
881 : :
882 [ # # ]: 0 : const SvxBoxItem& rOldBox = (const SvxBoxItem&)rSet.Get(ATTR_BORDER);
883 [ # # ][ # # ]: 0 : if ( rOldBox.GetTop() || rOldBox.GetBottom() || rOldBox.GetLeft() || rOldBox.GetRight() )
[ # # ][ # # ]
[ # # ]
884 : : {
885 [ # # ]: 0 : SvxBoxItem aNew( ATTR_BORDER );
886 [ # # ][ # # ]: 0 : aNew.SetLine( rOldBox.GetLine( BOX_LINE_TOP ), BOX_LINE_LEFT );
887 [ # # ][ # # ]: 0 : aNew.SetLine( rOldBox.GetLine( BOX_LINE_LEFT ), BOX_LINE_TOP );
888 [ # # ][ # # ]: 0 : aNew.SetLine( rOldBox.GetLine( BOX_LINE_BOTTOM ), BOX_LINE_RIGHT );
889 [ # # ][ # # ]: 0 : aNew.SetLine( rOldBox.GetLine( BOX_LINE_RIGHT ), BOX_LINE_BOTTOM );
890 [ # # ][ # # ]: 0 : aNew.SetDistance( rOldBox.GetDistance( BOX_LINE_TOP ), BOX_LINE_LEFT );
891 [ # # ][ # # ]: 0 : aNew.SetDistance( rOldBox.GetDistance( BOX_LINE_LEFT ), BOX_LINE_TOP );
892 [ # # ][ # # ]: 0 : aNew.SetDistance( rOldBox.GetDistance( BOX_LINE_BOTTOM ), BOX_LINE_RIGHT );
893 [ # # ][ # # ]: 0 : aNew.SetDistance( rOldBox.GetDistance( BOX_LINE_RIGHT ), BOX_LINE_BOTTOM );
894 [ # # ][ # # ]: 0 : rNewSet.Put( aNew );
895 : : }
896 : :
897 [ # # ]: 0 : const ScMergeAttr& rOldMerge = (const ScMergeAttr&)rSet.Get(ATTR_MERGE);
898 [ # # ]: 0 : if (rOldMerge.IsMerged())
899 : : rNewSet.Put( ScMergeAttr( Min(
900 : 0 : static_cast<SCsCOL>(rOldMerge.GetRowMerge()),
901 : 0 : static_cast<SCsCOL>(MAXCOL+1 - (nAttrRow2-nRow1))),
902 : : Min(
903 : 0 : static_cast<SCsROW>(rOldMerge.GetColMerge()),
904 [ # # ][ # # ]: 0 : static_cast<SCsROW>(MAXROW+1 - (nCol-nCol1)))));
[ # # ]
905 [ # # ]: 0 : const ScMergeFlagAttr& rOldFlag = (const ScMergeFlagAttr&)rSet.Get(ATTR_MERGE_FLAG);
906 [ # # ]: 0 : if (rOldFlag.IsOverlapped())
907 : : {
908 : 0 : sal_Int16 nNewFlags = rOldFlag.GetValue() & ~( SC_MF_HOR | SC_MF_VER );
909 [ # # ]: 0 : if ( nNewFlags )
910 [ # # ][ # # ]: 0 : rNewSet.Put( ScMergeFlagAttr( nNewFlags ) );
[ # # ]
911 : : else
912 [ # # ]: 0 : rNewSet.ClearItem( ATTR_MERGE_FLAG );
913 : : }
914 : :
915 [ # # ]: 0 : for (nRow = nAttrRow1; nRow<=nAttrRow2; nRow++)
916 : : pTransClip->SetPattern( static_cast<SCCOL>(nRow-nRow1),
917 [ # # ][ # # ]: 0 : static_cast<SCROW>(nCol-nCol1), aNewPattern, true);
918 : : }
919 : : }
920 : : }
921 : :
922 : 0 : delete pAttrIter;
923 : : }
924 : 0 : }
925 : :
926 : :
927 : 397 : void ScTable::StartAllListeners()
928 : : {
929 [ + + ]: 406925 : for (SCCOL i=0; i<=MAXCOL; i++)
930 : 406528 : aCol[i].StartAllListeners();
931 : 397 : }
932 : :
933 : :
934 : 49 : void ScTable::StartNeededListeners()
935 : : {
936 [ + + ]: 50225 : for (SCCOL i=0; i<=MAXCOL; i++)
937 : 50176 : aCol[i].StartNeededListeners();
938 : 49 : }
939 : :
940 : :
941 : 25 : void ScTable::BroadcastInArea( SCCOL nCol1, SCROW nRow1,
942 : : SCCOL nCol2, SCROW nRow2 )
943 : : {
944 [ - + ]: 25 : if (nCol2 > MAXCOL) nCol2 = MAXCOL;
945 [ - + ]: 25 : if (nRow2 > MAXROW) nRow2 = MAXROW;
946 [ + - ][ + - ]: 25 : if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
[ + - ]
947 [ + + ]: 120 : for (SCCOL i = nCol1; i <= nCol2; i++)
948 : 95 : aCol[i].BroadcastInArea( nRow1, nRow2 );
949 : 25 : }
950 : :
951 : :
952 : 25 : void ScTable::StartListeningInArea( SCCOL nCol1, SCROW nRow1,
953 : : SCCOL nCol2, SCROW nRow2 )
954 : : {
955 [ - + ]: 25 : if (nCol2 > MAXCOL) nCol2 = MAXCOL;
956 [ - + ]: 25 : if (nRow2 > MAXROW) nRow2 = MAXROW;
957 [ + - ][ + - ]: 25 : if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
[ + - ]
958 [ + + ]: 120 : for (SCCOL i = nCol1; i <= nCol2; i++)
959 : 95 : aCol[i].StartListeningInArea( nRow1, nRow2 );
960 : 25 : }
961 : :
962 : :
963 : 971 : void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
964 : : sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
965 : : const ScMarkData* pMarkData,
966 : : bool bAsLink, bool bColRowFlags)
967 : : {
968 [ + - ][ - + ]: 971 : if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2))
[ - + ]
969 : 0 : return;
970 : :
971 [ + + ]: 971 : if (nFlags)
972 [ + + ]: 64865 : for (SCCOL i = nCol1; i <= nCol2; i++)
973 : 63914 : aCol[i].CopyToColumn(nRow1, nRow2, nFlags, bMarked,
974 : 63914 : pDestTab->aCol[i], pMarkData, bAsLink);
975 : :
976 [ + + ]: 971 : if (!bColRowFlags) // Spaltenbreiten/Zeilenhoehen/Flags
977 : 4 : return;
978 : :
979 : : //remove old notes
980 [ + + ]: 967 : if (nFlags & IDF_CONTENTS)
981 : 320 : pDestTab->maNotes.erase(nCol1, nRow1, nCol2, nRow2);
982 : :
983 : 967 : bool bAddNotes = nFlags & (IDF_NOTE | IDF_ADDNOTES);
984 [ + + ]: 967 : if (bAddNotes)
985 : : {
986 : 277 : bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0;
987 : 277 : pDestTab->maNotes.CopyFromClip(maNotes, pDestTab->pDocument, nCol1, nRow1, nCol2, nRow2, 0, 0, pDestTab->nTab, bCloneCaption);
988 : : }
989 : :
990 [ + + ]: 967 : if (pDBDataNoName)
991 : : {
992 [ + - ][ + - ]: 443 : ScDBData* pNewDBData = new ScDBData(*pDBDataNoName);
993 : : SCCOL aCol1, aCol2;
994 : : SCROW aRow1, aRow2;
995 : : SCTAB aTab;
996 [ + - ]: 443 : pNewDBData->GetArea(aTab, aCol1, aRow1, aCol2, aRow2);
997 [ + - ]: 443 : pNewDBData->MoveTo(pDestTab->nTab, aCol1, aRow1, aCol2, aRow2);
998 [ + - ]: 443 : pDestTab->SetAnonymousDBData(pNewDBData);
999 : : }
1000 : : // Charts muessen beim Ein-/Ausblenden angepasst werden
1001 : 967 : ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection();
1002 : :
1003 : 967 : bool bFlagChange = false;
1004 : :
1005 [ + + ][ + - ]: 967 : bool bWidth = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
[ + + ][ + + ]
1006 [ + + ][ + + ]: 967 : bool bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights);
[ + - ][ + + ]
1007 : :
1008 [ + + ][ + + ]: 967 : if (bWidth || bHeight)
1009 : : {
1010 : 71 : pDestTab->IncRecalcLevel();
1011 : :
1012 [ + + ]: 71 : if (bWidth)
1013 : : {
1014 [ + + ]: 37944 : for (SCCOL i = nCol1; i <= nCol2; ++i)
1015 : : {
1016 : 37898 : bool bThisHidden = ColHidden(i);
1017 : 37898 : bool bHiddenChange = (pDestTab->ColHidden(i) != bThisHidden);
1018 [ + + ][ + - ]: 37898 : bool bChange = bHiddenChange || (pDestTab->pColWidth[i] != pColWidth[i]);
1019 : 37898 : pDestTab->pColWidth[i] = pColWidth[i];
1020 : 37898 : pDestTab->pColFlags[i] = pColFlags[i];
1021 : 37898 : pDestTab->SetColHidden(i, i, bThisHidden);
1022 : : //! Aenderungen zusammenfassen?
1023 [ # # ][ - + ]: 37898 : if (bHiddenChange && pCharts)
1024 [ # # ]: 0 : pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, MAXROW, nTab ));
1025 : :
1026 [ + + ]: 37898 : if (bChange)
1027 : 22 : bFlagChange = true;
1028 : : }
1029 : 46 : pDestTab->SetColManualBreaks( maColManualBreaks);
1030 : : }
1031 : :
1032 [ + + ]: 71 : if (bHeight)
1033 : : {
1034 : 62 : bool bChange = pDestTab->GetRowHeight(nRow1, nRow2) != GetRowHeight(nRow1, nRow2);
1035 : :
1036 [ + + ]: 62 : if (bChange)
1037 : 41 : bFlagChange = true;
1038 : :
1039 : 62 : pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0);
1040 : 62 : pDestTab->pRowFlags->CopyFrom(*pRowFlags, nRow1, nRow2);
1041 : :
1042 : : // Hidden flags.
1043 [ + + ]: 154 : for (SCROW i = nRow1; i <= nRow2; ++i)
1044 : : {
1045 : : SCROW nLastRow;
1046 [ + - ]: 92 : bool bHidden = RowHidden(i, NULL, &nLastRow);
1047 [ + + ]: 92 : if (nLastRow >= nRow2)
1048 : : // the last row shouldn't exceed the upper bound the caller specified.
1049 : 62 : nLastRow = nRow2;
1050 : :
1051 [ + - ]: 92 : bool bHiddenChanged = pDestTab->SetRowHidden(i, nLastRow, bHidden);
1052 [ + + ][ + + ]: 92 : if (bHiddenChanged && pCharts)
1053 : : // Hidden flags differ.
1054 [ + - ]: 3 : pCharts->SetRangeDirty(ScRange(0, i, nTab, MAXCOL, nLastRow, nTab));
1055 : :
1056 [ + + ]: 92 : if (bHiddenChanged)
1057 : 14 : bFlagChange = true;
1058 : :
1059 : : // Jump to the last row of the identical flag segment.
1060 : 92 : i = nLastRow;
1061 : : }
1062 : :
1063 : : // Filtered flags.
1064 [ + + ]: 148 : for (SCROW i = nRow1; i <= nRow2; ++i)
1065 : : {
1066 : : SCROW nLastRow;
1067 [ + - ]: 86 : bool bFiltered = RowFiltered(i, NULL, &nLastRow);
1068 [ + + ]: 86 : if (nLastRow >= nRow2)
1069 : : // the last row shouldn't exceed the upper bound the caller specified.
1070 : 62 : nLastRow = nRow2;
1071 [ + - ]: 86 : pDestTab->SetRowFiltered(i, nLastRow, bFiltered);
1072 : 86 : i = nLastRow;
1073 : : }
1074 : 62 : pDestTab->SetRowManualBreaks( maRowManualBreaks);
1075 : : }
1076 : 71 : pDestTab->DecRecalcLevel();
1077 : : }
1078 : :
1079 [ + + ]: 967 : if (bFlagChange)
1080 : 43 : pDestTab->InvalidatePageBreaks();
1081 : :
1082 : 971 : pDestTab->SetOutlineTable( pOutlineTable ); // auch nur wenn bColRowFlags
1083 : : }
1084 : :
1085 : :
1086 : 6 : void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1087 : : sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
1088 : : const ScMarkData* pMarkData)
1089 : : {
1090 [ + - ][ + - ]: 6 : if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
[ + - ]
1091 : : {
1092 [ - + ][ # # ]: 6 : bool bWidth = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
[ # # ][ # # ]
1093 [ + - ][ - + ]: 6 : bool bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights);
[ # # ][ # # ]
1094 : :
1095 [ + - ][ - + ]: 6 : if (bWidth||bHeight)
1096 : 0 : IncRecalcLevel();
1097 : :
1098 [ + + ]: 6150 : for ( SCCOL i = 0; i <= MAXCOL; i++)
1099 : : {
1100 [ + - ][ + + ]: 6144 : if ( i >= nCol1 && i <= nCol2 )
1101 : 36 : aCol[i].UndoToColumn(nRow1, nRow2, nFlags, bMarked, pDestTab->aCol[i],
1102 : 18 : pMarkData);
1103 : : else
1104 : 6126 : aCol[i].CopyToColumn(0, MAXROW, IDF_FORMULA, false, pDestTab->aCol[i]);
1105 : : }
1106 : :
1107 : : //remove old notes
1108 [ + - ]: 6 : if (nFlags & IDF_CONTENTS)
1109 : 6 : pDestTab->maNotes.erase(nCol1, nRow1, nCol2, nRow2);
1110 : :
1111 : 6 : bool bAddNotes = nFlags & (IDF_NOTE | IDF_ADDNOTES);
1112 [ + - ]: 6 : if (bAddNotes)
1113 : : {
1114 : 6 : bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0;
1115 : 6 : pDestTab->maNotes.CopyFromClip(maNotes, pDocument, nCol1, nRow1, nCol2, nRow2, 0, 0, pDestTab->nTab, bCloneCaption);
1116 : : }
1117 : :
1118 [ + - ][ - + ]: 6 : if (bWidth||bHeight)
1119 : : {
1120 [ # # ]: 0 : if (bWidth)
1121 : : {
1122 [ # # ]: 0 : for (SCCOL i=nCol1; i<=nCol2; i++)
1123 : 0 : pDestTab->pColWidth[i] = pColWidth[i];
1124 : 0 : pDestTab->SetColManualBreaks( maColManualBreaks);
1125 : : }
1126 [ # # ]: 0 : if (bHeight)
1127 : : {
1128 : 0 : pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0);
1129 : 0 : pDestTab->SetRowManualBreaks( maRowManualBreaks);
1130 : : }
1131 : 0 : DecRecalcLevel();
1132 : : }
1133 : : }
1134 : 6 : }
1135 : :
1136 : :
1137 : 0 : void ScTable::CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const
1138 : : {
1139 [ # # ]: 0 : for (SCCOL i=0; i<=MAXCOL; i++)
1140 : 0 : aCol[i].CopyUpdated( pPosTab->aCol[i], pDestTab->aCol[i] );
1141 : :
1142 : : // insert notes with captions
1143 [ # # ][ # # ]: 0 : for(ScNotes::iterator itr = pDestTab->maNotes.begin(); itr != pDestTab->maNotes.end(); ++itr)
[ # # ][ # # ]
[ # # ]
1144 : : {
1145 [ # # ]: 0 : SCCOL nCol = itr->first.first;
1146 [ # # ]: 0 : SCROW nRow = itr->first.second;
1147 [ # # ]: 0 : ScPostIt* pPostIt = itr->second;
1148 : :
1149 [ # # ][ # # ]: 0 : pDestTab->maNotes.insert(nCol, nRow, pPostIt->Clone( ScAddress(nCol, nRow, nTab),*pDestTab->pDocument, ScAddress(nCol, nRow, pDestTab->nTab), true ));
1150 : : }
1151 : 0 : }
1152 : :
1153 : 16631 : void ScTable::InvalidateTableArea()
1154 : : {
1155 : 16631 : bTableAreaValid = false;
1156 : 16631 : }
1157 : :
1158 : 64811 : void ScTable::InvalidatePageBreaks()
1159 : : {
1160 : 64811 : mbPageBreaksValid = false;
1161 : 64811 : }
1162 : :
1163 : 0 : void ScTable::CopyScenarioTo( ScTable* pDestTab ) const
1164 : : {
1165 : : OSL_ENSURE( bScenario, "bScenario == FALSE" );
1166 : :
1167 [ # # ]: 0 : for (SCCOL i=0; i<=MAXCOL; i++)
1168 : 0 : aCol[i].CopyScenarioTo( pDestTab->aCol[i] );
1169 : 0 : }
1170 : :
1171 : 0 : void ScTable::CopyScenarioFrom( const ScTable* pSrcTab )
1172 : : {
1173 : : OSL_ENSURE( bScenario, "bScenario == FALSE" );
1174 : :
1175 [ # # ]: 0 : for (SCCOL i=0; i<=MAXCOL; i++)
1176 : 0 : aCol[i].CopyScenarioFrom( pSrcTab->aCol[i] );
1177 : 0 : }
1178 : :
1179 : 1 : void ScTable::MarkScenarioIn( ScMarkData& rDestMark, sal_uInt16 nNeededBits ) const
1180 : : {
1181 : : OSL_ENSURE( bScenario, "bScenario == FALSE" );
1182 : :
1183 [ - + ]: 1 : if ( ( nScenarioFlags & nNeededBits ) != nNeededBits ) // alle Bits gesetzt?
1184 : 1 : return;
1185 : :
1186 [ + + ]: 1025 : for (SCCOL i=0; i<=MAXCOL; i++)
1187 : 1024 : aCol[i].MarkScenarioIn( rDestMark );
1188 : : }
1189 : :
1190 : 0 : bool ScTable::HasScenarioRange( const ScRange& rRange ) const
1191 : : {
1192 : : OSL_ENSURE( bScenario, "bScenario == FALSE" );
1193 : :
1194 : 0 : ScRange aTabRange = rRange;
1195 : 0 : aTabRange.aStart.SetTab( nTab );
1196 : 0 : aTabRange.aEnd.SetTab( nTab );
1197 : :
1198 [ # # ]: 0 : const ScRangeList* pList = GetScenarioRanges();
1199 : :
1200 [ # # ]: 0 : if (pList)
1201 : : {
1202 [ # # ][ # # ]: 0 : for ( size_t j = 0, n = pList->size(); j < n; j++ )
1203 : : {
1204 [ # # ]: 0 : const ScRange* pR = (*pList)[j];
1205 [ # # ][ # # ]: 0 : if ( pR->Intersects( aTabRange ) )
1206 : 0 : return true;
1207 : : }
1208 : : }
1209 : :
1210 : 0 : return false;
1211 : : }
1212 : :
1213 : 1 : void ScTable::InvalidateScenarioRanges()
1214 : : {
1215 [ + - ]: 1 : delete pScenarioRanges;
1216 : 1 : pScenarioRanges = NULL;
1217 : 1 : }
1218 : :
1219 : 1 : const ScRangeList* ScTable::GetScenarioRanges() const
1220 : : {
1221 : : OSL_ENSURE( bScenario, "bScenario == FALSE" );
1222 : :
1223 [ + - ]: 1 : if (!pScenarioRanges)
1224 : : {
1225 [ + - ][ + - ]: 1 : ((ScTable*)this)->pScenarioRanges = new ScRangeList;
1226 [ + - ]: 1 : ScMarkData aMark;
1227 [ + - ]: 1 : MarkScenarioIn( aMark, 0 ); // immer
1228 [ + - ][ + - ]: 1 : aMark.FillRangeListWithMarks( pScenarioRanges, false );
1229 : : }
1230 : 1 : return pScenarioRanges;
1231 : : }
1232 : :
1233 : 0 : bool ScTable::TestCopyScenarioTo( const ScTable* pDestTab ) const
1234 : : {
1235 : : OSL_ENSURE( bScenario, "bScenario == FALSE" );
1236 : :
1237 [ # # ]: 0 : if (!pDestTab->IsProtected())
1238 : 0 : return true;
1239 : :
1240 : 0 : bool bOk = true;
1241 [ # # ][ # # ]: 0 : for (SCCOL i=0; i<=MAXCOL && bOk; i++)
[ # # ]
1242 : 0 : bOk = aCol[i].TestCopyScenarioTo( pDestTab->aCol[i] );
1243 : 0 : return bOk;
1244 : : }
1245 : :
1246 : 12479 : void ScTable::PutCell( SCCOL nCol, SCROW nRow, ScBaseCell* pCell )
1247 : : {
1248 [ + - ]: 12479 : if (ValidColRow(nCol,nRow))
1249 : : {
1250 [ + + ]: 12479 : if (pCell)
1251 : 11579 : aCol[nCol].Insert( nRow, pCell );
1252 : : else
1253 : 900 : aCol[nCol].Delete( nRow );
1254 : : }
1255 : 12479 : }
1256 : :
1257 : :
1258 : 0 : void ScTable::PutCell( SCCOL nCol, SCROW nRow, sal_uLong nFormatIndex, ScBaseCell* pCell )
1259 : : {
1260 [ # # ]: 0 : if (ValidColRow(nCol,nRow))
1261 : : {
1262 [ # # ]: 0 : if (pCell)
1263 : 0 : aCol[nCol].Insert( nRow, nFormatIndex, pCell );
1264 : : else
1265 : 0 : aCol[nCol].Delete( nRow );
1266 : : }
1267 : 0 : }
1268 : :
1269 : :
1270 : 8711 : void ScTable::PutCell( const ScAddress& rPos, ScBaseCell* pCell )
1271 : : {
1272 [ + + ]: 8711 : if (pCell)
1273 : 8581 : aCol[rPos.Col()].Insert( rPos.Row(), pCell );
1274 : : else
1275 : 130 : aCol[rPos.Col()].Delete( rPos.Row() );
1276 : 8711 : }
1277 : :
1278 : :
1279 : 4748 : bool ScTable::SetString( SCCOL nCol, SCROW nRow, SCTAB nTabP, const String& rString,
1280 : : ScSetStringParam* pParam )
1281 : : {
1282 [ + - ]: 4748 : if (ValidColRow(nCol,nRow))
1283 : 4748 : return aCol[nCol].SetString(
1284 : 4748 : nRow, nTabP, rString, pDocument->GetAddressConvention(), pParam );
1285 : : else
1286 : 4748 : return false;
1287 : : }
1288 : :
1289 : :
1290 : 25904 : void ScTable::SetValue( SCCOL nCol, SCROW nRow, const double& rVal )
1291 : : {
1292 [ + - ]: 25904 : if (ValidColRow(nCol, nRow))
1293 : 25904 : aCol[nCol].SetValue( nRow, rVal );
1294 : 25904 : }
1295 : :
1296 : :
1297 : 17785 : void ScTable::GetString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const
1298 : : {
1299 [ + - ]: 17785 : if (ValidColRow(nCol,nRow))
1300 : 17785 : aCol[nCol].GetString( nRow, rString );
1301 : : else
1302 : 0 : rString = rtl::OUString();
1303 : 17785 : }
1304 : :
1305 : :
1306 : 1678 : void ScTable::GetInputString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const
1307 : : {
1308 [ + - ]: 1678 : if (ValidColRow(nCol,nRow))
1309 : 1678 : aCol[nCol].GetInputString( nRow, rString );
1310 : : else
1311 : 0 : rString = rtl::OUString();
1312 : 1678 : }
1313 : :
1314 : :
1315 : 1619 : double ScTable::GetValue( SCCOL nCol, SCROW nRow ) const
1316 : : {
1317 [ + - ]: 1619 : if (ValidColRow( nCol, nRow ))
1318 : 1619 : return aCol[nCol].GetValue( nRow );
1319 : 1619 : return 0.0;
1320 : : }
1321 : :
1322 : :
1323 : 42 : void ScTable::GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula )
1324 : : {
1325 [ + - ]: 42 : if (ValidColRow(nCol,nRow))
1326 : 42 : aCol[nCol].GetFormula( nRow, rFormula );
1327 : : else
1328 : 0 : rFormula = rtl::OUString();
1329 : 42 : }
1330 : :
1331 : 150910 : ScNotes* ScTable::GetNotes()
1332 : : {
1333 : 150910 : return &maNotes;
1334 : : }
1335 : :
1336 : :
1337 : 65074 : void ScTable::InitializeNoteCaptions( bool bForced )
1338 : : {
1339 [ - + ][ # # ]: 65074 : if( mxUninitNotes.get() && (bForced || pDocument->IsUndoEnabled()) )
[ # # ][ - + ]
1340 : : {
1341 [ # # ][ # # ]: 0 : for( ScAddress2DVec::iterator aIt = mxUninitNotes->begin(), aEnd = mxUninitNotes->end(); aIt != aEnd; ++aIt )
[ # # ]
1342 [ # # ][ # # ]: 0 : if( ScPostIt* pNote = maNotes.findByAddress( aIt->first, aIt->second ) )
[ # # ][ # # ]
1343 [ # # ][ # # ]: 0 : pNote->GetOrCreateCaption( ScAddress( aIt->first, aIt->second, nTab ) );
[ # # ]
1344 : 0 : mxUninitNotes.reset();
1345 : : }
1346 : 65074 : }
1347 : :
1348 : 1510 : CellType ScTable::GetCellType( SCCOL nCol, SCROW nRow ) const
1349 : : {
1350 [ + - ]: 1510 : if (ValidColRow( nCol, nRow ))
1351 : 1510 : return aCol[nCol].GetCellType( nRow );
1352 : 1510 : return CELLTYPE_NONE;
1353 : : }
1354 : :
1355 : :
1356 : 1099 : ScBaseCell* ScTable::GetCell( SCCOL nCol, SCROW nRow ) const
1357 : : {
1358 [ + - ]: 1099 : if (ValidColRow( nCol, nRow ))
1359 : 1099 : return aCol[nCol].GetCell( nRow );
1360 : :
1361 : : OSL_FAIL("GetCell ausserhalb");
1362 : 1099 : return NULL;
1363 : : }
1364 : :
1365 : 628 : void ScTable::GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const
1366 : : {
1367 : 628 : rCol = 0;
1368 : 628 : rRow = MAXROW+1;
1369 [ - + ][ # # ]: 628 : while (aCol[rCol].IsEmptyData() && rCol < MAXCOL)
[ - + ]
1370 : 0 : ++rCol;
1371 : 628 : SCCOL nCol = rCol;
1372 [ + + ][ + + ]: 32539 : while (nCol <= MAXCOL && rRow > 0)
[ + + ]
1373 : : {
1374 [ + + ]: 31911 : if (!aCol[nCol].IsEmptyData())
1375 [ + - ]: 1491 : rRow = ::std::min( rRow, aCol[nCol].GetFirstDataPos());
1376 : 31911 : ++nCol;
1377 : : }
1378 : 628 : }
1379 : :
1380 : 737 : void ScTable::GetLastDataPos(SCCOL& rCol, SCROW& rRow) const
1381 : : {
1382 : 737 : rCol = MAXCOL;
1383 : 737 : rRow = 0;
1384 [ + + ][ + - ]: 745894 : while (aCol[rCol].IsEmptyData() && (rCol > 0))
[ + + ]
1385 : 745157 : rCol--;
1386 : 737 : SCCOL nCol = rCol;
1387 [ + + ][ + - ]: 10268 : while (nCol >= 0 && rRow < MAXROW)
[ + + ]
1388 [ + - ]: 9531 : rRow = ::std::max( rRow, aCol[nCol--].GetLastDataPos());
1389 : 737 : }
1390 : :
1391 : :
1392 : 584 : bool ScTable::HasData( SCCOL nCol, SCROW nRow ) const
1393 : : {
1394 [ + - ]: 584 : if (ValidColRow(nCol,nRow))
1395 : 584 : return aCol[nCol].HasDataAt( nRow );
1396 : : else
1397 : 584 : return false;
1398 : : }
1399 : :
1400 : :
1401 : 15 : bool ScTable::HasStringData( SCCOL nCol, SCROW nRow ) const
1402 : : {
1403 [ + - ]: 15 : if (ValidColRow(nCol,nRow))
1404 : 15 : return aCol[nCol].HasStringData( nRow );
1405 : : else
1406 : 15 : return false;
1407 : : }
1408 : :
1409 : :
1410 : 2150 : bool ScTable::HasValueData( SCCOL nCol, SCROW nRow ) const
1411 : : {
1412 [ + - ]: 2150 : if (ValidColRow(nCol,nRow))
1413 : 2150 : return aCol[nCol].HasValueData( nRow );
1414 : : else
1415 : 2150 : return false;
1416 : : }
1417 : :
1418 : :
1419 : 0 : bool ScTable::HasStringCells( SCCOL nStartCol, SCROW nStartRow,
1420 : : SCCOL nEndCol, SCROW nEndRow ) const
1421 : : {
1422 [ # # ]: 0 : if ( ValidCol(nEndCol) )
1423 [ # # ]: 0 : for ( SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++ )
1424 [ # # ]: 0 : if (aCol[nCol].HasStringCells(nStartRow, nEndRow))
1425 : 0 : return true;
1426 : :
1427 : 0 : return false;
1428 : : }
1429 : :
1430 : :
1431 : 343 : void ScTable::SetDirtyVar()
1432 : : {
1433 [ + + ]: 351575 : for (SCCOL i=0; i<=MAXCOL; i++)
1434 : 351232 : aCol[i].SetDirtyVar();
1435 : 343 : }
1436 : :
1437 : :
1438 : 806 : void ScTable::SetDirty()
1439 : : {
1440 : 806 : bool bOldAutoCalc = pDocument->GetAutoCalc();
1441 : 806 : pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden
1442 [ + + ]: 826150 : for (SCCOL i=0; i<=MAXCOL; i++)
1443 : 825344 : aCol[i].SetDirty();
1444 : 806 : pDocument->SetAutoCalc( bOldAutoCalc );
1445 : 806 : }
1446 : :
1447 : :
1448 : 144 : void ScTable::SetDirty( const ScRange& rRange )
1449 : : {
1450 : 144 : bool bOldAutoCalc = pDocument->GetAutoCalc();
1451 : 144 : pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden
1452 : 144 : SCCOL nCol2 = rRange.aEnd.Col();
1453 [ + + ]: 4440 : for (SCCOL i=rRange.aStart.Col(); i<=nCol2; i++)
1454 : 4296 : aCol[i].SetDirty( rRange );
1455 : 144 : pDocument->SetAutoCalc( bOldAutoCalc );
1456 : 144 : }
1457 : :
1458 : :
1459 : 60 : void ScTable::SetTableOpDirty( const ScRange& rRange )
1460 : : {
1461 : 60 : bool bOldAutoCalc = pDocument->GetAutoCalc();
1462 : 60 : pDocument->SetAutoCalc( false ); // no multiple recalculation
1463 : 60 : SCCOL nCol2 = rRange.aEnd.Col();
1464 [ + + ]: 120 : for (SCCOL i=rRange.aStart.Col(); i<=nCol2; i++)
1465 : 60 : aCol[i].SetTableOpDirty( rRange );
1466 : 60 : pDocument->SetAutoCalc( bOldAutoCalc );
1467 : 60 : }
1468 : :
1469 : :
1470 : 180 : void ScTable::SetDirtyAfterLoad()
1471 : : {
1472 : 180 : bool bOldAutoCalc = pDocument->GetAutoCalc();
1473 : 180 : pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden
1474 [ + + ]: 184500 : for (SCCOL i=0; i<=MAXCOL; i++)
1475 : 184320 : aCol[i].SetDirtyAfterLoad();
1476 : 180 : pDocument->SetAutoCalc( bOldAutoCalc );
1477 : 180 : }
1478 : :
1479 : :
1480 : 49 : void ScTable::SetRelNameDirty()
1481 : : {
1482 : 49 : bool bOldAutoCalc = pDocument->GetAutoCalc();
1483 : 49 : pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden
1484 [ + + ]: 50225 : for (SCCOL i=0; i<=MAXCOL; i++)
1485 : 50176 : aCol[i].SetRelNameDirty();
1486 : 49 : pDocument->SetAutoCalc( bOldAutoCalc );
1487 : 49 : }
1488 : :
1489 : :
1490 : 1680 : void ScTable::SetLoadingMedium(bool bLoading)
1491 : : {
1492 : 1680 : mpRowHeights->enableTreeSearch(!bLoading);
1493 : 1680 : }
1494 : :
1495 : :
1496 : 343 : void ScTable::CalcAll()
1497 : : {
1498 [ + + ]: 351575 : for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CalcAll();
1499 : 343 : }
1500 : :
1501 : :
1502 : 8 : void ScTable::CompileAll()
1503 : : {
1504 [ + + ]: 8200 : for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].CompileAll();
1505 : :
1506 [ + - ]: 8 : if(mpCondFormatList)
1507 : 8 : mpCondFormatList->CompileAll();
1508 : 8 : }
1509 : :
1510 : :
1511 : 224 : void ScTable::CompileXML( ScProgress& rProgress )
1512 : : {
1513 [ + + ]: 224 : if (mpRangeName)
1514 : 12 : mpRangeName->CompileUnresolvedXML();
1515 : :
1516 [ + + ]: 229600 : for (SCCOL i=0; i <= MAXCOL; i++)
1517 : : {
1518 : 229376 : aCol[i].CompileXML( rProgress );
1519 : : }
1520 : :
1521 [ + - ]: 224 : if(mpCondFormatList)
1522 : 224 : mpCondFormatList->CompileXML();
1523 : 224 : }
1524 : :
1525 : 180 : void ScTable::CalcAfterLoad()
1526 : : {
1527 [ + + ]: 184500 : for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].CalcAfterLoad();
1528 : 180 : }
1529 : :
1530 : :
1531 : 1375 : void ScTable::ResetChanged( const ScRange& rRange )
1532 : : {
1533 : 1375 : SCCOL nStartCol = rRange.aStart.Col();
1534 : 1375 : SCROW nStartRow = rRange.aStart.Row();
1535 : 1375 : SCCOL nEndCol = rRange.aEnd.Col();
1536 : 1375 : SCROW nEndRow = rRange.aEnd.Row();
1537 : :
1538 [ + + ]: 13930 : for (SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
1539 : 12555 : aCol[nCol].ResetChanged(nStartRow, nEndRow);
1540 : 1375 : }
1541 : :
1542 : : // Attribute
1543 : :
1544 : 11898 : const SfxPoolItem* ScTable::GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const
1545 : : {
1546 [ + - ]: 11898 : if (ValidColRow(nCol,nRow))
1547 : 11898 : return aCol[nCol].GetAttr( nRow, nWhich );
1548 : : else
1549 : 11898 : return NULL;
1550 : : }
1551 : :
1552 : :
1553 : 1237 : sal_uLong ScTable::GetNumberFormat( SCCOL nCol, SCROW nRow ) const
1554 : : {
1555 [ + - ]: 1237 : if (ValidColRow(nCol,nRow))
1556 : 1237 : return aCol[nCol].GetNumberFormat( nRow );
1557 : : else
1558 : 1237 : return 0;
1559 : : }
1560 : :
1561 : 0 : sal_uInt32 ScTable::GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const
1562 : : {
1563 [ # # ][ # # ]: 0 : if (!ValidCol(nCol) || !ValidRow(nStartRow) || !ValidRow(nEndRow))
[ # # ][ # # ]
1564 : 0 : return 0;
1565 : :
1566 : 0 : return aCol[nCol].GetNumberFormat(nStartRow, nEndRow);
1567 : : }
1568 : :
1569 : :
1570 : 36560 : const ScPatternAttr* ScTable::GetPattern( SCCOL nCol, SCROW nRow ) const
1571 : : {
1572 [ + - ]: 36560 : if (ValidColRow(nCol,nRow))
1573 : 36560 : return aCol[nCol].GetPattern( nRow );
1574 : : else
1575 : : {
1576 : : OSL_FAIL("wrong column or row");
1577 : 36560 : return pDocument->GetDefPattern(); // for safety
1578 : : }
1579 : : }
1580 : :
1581 : :
1582 : 0 : const ScPatternAttr* ScTable::GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const
1583 : : {
1584 [ # # ][ # # ]: 0 : if ( ValidColRow( nCol, nStartRow ) && ValidRow( nEndRow ) && (nStartRow <= nEndRow) )
[ # # ][ # # ]
1585 : 0 : return aCol[nCol].GetMostUsedPattern( nStartRow, nEndRow );
1586 : : else
1587 : 0 : return NULL;
1588 : : }
1589 : :
1590 : :
1591 : 13700 : bool ScTable::HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal_uInt16 nMask ) const
1592 : : {
1593 : 13700 : bool bFound = false;
1594 [ + + ][ + + ]: 8079785 : for (SCCOL i=nCol1; i<=nCol2 && !bFound; i++)
[ + + ]
1595 : 8066085 : bFound |= aCol[i].HasAttrib( nRow1, nRow2, nMask );
1596 : 13700 : return bFound;
1597 : : }
1598 : :
1599 : :
1600 : 0 : bool ScTable::HasAttribSelection( const ScMarkData& rMark, sal_uInt16 nMask ) const
1601 : : {
1602 : 0 : bool bFound = false;
1603 [ # # ][ # # ]: 0 : for (SCCOL i=0; i<=MAXCOL && !bFound; i++)
[ # # ]
1604 : 0 : bFound |= aCol[i].HasAttribSelection( rMark, nMask );
1605 : 0 : return bFound;
1606 : : }
1607 : :
1608 : :
1609 : 4417 : bool ScTable::ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
1610 : : SCCOL& rEndCol, SCROW& rEndRow,
1611 : : bool bRefresh )
1612 : : {
1613 [ + - ][ - + ]: 4417 : if (!(ValidCol(nStartCol) && ValidCol(rEndCol)))
[ - + ]
1614 : : {
1615 : : OSL_FAIL("ScTable::ExtendMerge: invalid column number");
1616 : 0 : return false;
1617 : : }
1618 : 4417 : bool bFound = false;
1619 : 4417 : SCCOL nOldEndX = rEndCol;
1620 : 4417 : SCROW nOldEndY = rEndRow;
1621 [ + + ]: 14290 : for (SCCOL i=nStartCol; i<=nOldEndX; i++)
1622 : 9873 : bFound |= aCol[i].ExtendMerge( i, nStartRow, nOldEndY, rEndCol, rEndRow, bRefresh );
1623 : 4417 : return bFound;
1624 : : }
1625 : :
1626 : :
1627 : 297 : bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes ) const
1628 : : {
1629 [ + - ][ - + ]: 297 : if (!(ValidCol(nCol1) && ValidCol(nCol2)))
[ - + ]
1630 : : {
1631 : : OSL_FAIL("ScTable::IsBlockEmpty: invalid column number");
1632 : 0 : return false;
1633 : : }
1634 : 297 : bool bEmpty = true;
1635 [ + + ][ + + ]: 1794 : for (SCCOL i=nCol1; i<=nCol2 && bEmpty; i++)
[ + + ]
1636 : : {
1637 : 1497 : bEmpty = aCol[i].IsEmptyBlock( nRow1, nRow2 );
1638 [ + - ]: 1497 : if (!bIgnoreNotes)
1639 : : {
1640 [ + - ][ # # ]: 1497 : for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end() && bEmpty; ++itr)
[ + - ][ + - ]
[ - + ][ # # ]
[ + - ][ - + ]
[ # # ]
1641 : : {
1642 [ # # ]: 0 : SCCOL nCol = itr->first.first;
1643 [ # # ]: 0 : SCROW nRow = itr->first.second;
1644 : :
1645 [ # # ][ # # ]: 0 : if (nCol >= nCol1 && nCol <= nCol2 && nRow >= nRow1 && nRow <= nRow2)
[ # # ][ # # ]
1646 : 0 : bEmpty = false;
1647 : : }
1648 : : }
1649 : : }
1650 : 297 : return bEmpty;
1651 : : }
1652 : :
1653 : 550114 : SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1654 : : SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1655 : : const ScPatternAttr* pPattern, const SfxItemSet* pCondSet )
1656 : : {
1657 : : // Rueckgabe = neues nArrY
1658 : :
1659 : 550114 : sal_uInt8 nRotDir = pPattern->GetRotateDir( pCondSet );
1660 [ + + ]: 550114 : if ( nRotDir != SC_ROTDIR_NONE )
1661 : : {
1662 : 1269 : bool bHit = true;
1663 [ - + ]: 1269 : if ( nCol+1 < nX1 ) // column to the left
1664 : 0 : bHit = ( nRotDir != SC_ROTDIR_LEFT );
1665 [ - + ]: 1269 : else if ( nCol > nX2+1 ) // column to the right
1666 : 0 : bHit = ( nRotDir != SC_ROTDIR_RIGHT ); // SC_ROTDIR_STANDARD may now also be extended to the left
1667 : :
1668 [ + - ]: 1269 : if ( bHit )
1669 : : {
1670 : 1269 : double nFactor = 0.0;
1671 [ - + ]: 1269 : if ( nCol > nX2+1 )
1672 : : {
1673 : : long nRotVal = ((const SfxInt32Item&) pPattern->
1674 : 0 : GetItem( ATTR_ROTATE_VALUE, pCondSet )).GetValue();
1675 : 0 : double nRealOrient = nRotVal * F_PI18000; // 1/100 Grad
1676 : 0 : double nCos = cos( nRealOrient );
1677 : 0 : double nSin = sin( nRealOrient );
1678 : : //! begrenzen !!!
1679 : : //! zusaetzlich Faktor fuer unterschiedliche PPT X/Y !!!
1680 : :
1681 : : // bei SC_ROTDIR_LEFT kommt immer ein negativer Wert heraus,
1682 : : // wenn der Modus beruecksichtigt wird
1683 : 0 : nFactor = -fabs( nCos / nSin );
1684 : : }
1685 : :
1686 [ + + ]: 6666 : for ( SCROW nRow = nAttrRow1; nRow <= nAttrRow2; nRow++ )
1687 : : {
1688 [ + - ]: 5397 : if (!RowHidden(nRow))
1689 : : {
1690 : 5397 : bool bHitOne = true;
1691 [ - + ]: 5397 : if ( nCol > nX2+1 )
1692 : : {
1693 : : // reicht die gedrehte Zelle bis in den sichtbaren Bereich?
1694 : :
1695 : 0 : SCCOL nTouchedCol = nCol;
1696 : 0 : long nWidth = static_cast<long>(mpRowHeights->getValue(nRow) * nFactor);
1697 : : OSL_ENSURE(nWidth <= 0, "Richtung falsch");
1698 [ # # ][ # # ]: 0 : while ( nWidth < 0 && nTouchedCol > 0 )
[ # # ]
1699 : : {
1700 : 0 : --nTouchedCol;
1701 : 0 : nWidth += GetColWidth( nTouchedCol );
1702 : : }
1703 [ # # ]: 0 : if ( nTouchedCol > nX2 )
1704 : 0 : bHitOne = false;
1705 : : }
1706 : :
1707 [ + - ]: 5397 : if (bHitOne)
1708 : : {
1709 [ + - ][ + + ]: 9538 : while ( nArrY<nArrCount && pRowInfo[nArrY].nRowNo < nRow )
[ + + ]
1710 : 4141 : ++nArrY;
1711 [ + - ][ + - ]: 5397 : if ( nArrY<nArrCount && pRowInfo[nArrY].nRowNo == nRow )
1712 : 5397 : pRowInfo[nArrY].nRotMaxCol = nCol;
1713 : : }
1714 : : }
1715 : : }
1716 : : }
1717 : : }
1718 : :
1719 : 550114 : return nArrY;
1720 : : }
1721 : :
1722 : 532 : void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 )
1723 : : {
1724 [ + - ][ + - ]: 532 : if ( !pColWidth || !mpRowHeights || !pColFlags || !pRowFlags )
[ + - ][ - + ]
[ - + ]
1725 : : {
1726 : : OSL_FAIL( "Spalten-/Zeileninfo fehlt" );
1727 : 532 : return;
1728 : : }
1729 : :
1730 : : // nRotMaxCol ist auf SC_ROTMAX_NONE initialisiert, nRowNo ist schon gesetzt
1731 : :
1732 : 532 : SCROW nY1 = pRowInfo[0].nRowNo;
1733 : 532 : SCROW nY2 = pRowInfo[nArrCount-1].nRowNo;
1734 : :
1735 [ + + ]: 545300 : for (SCCOL nCol=0; nCol<=MAXCOL; nCol++)
1736 : : {
1737 [ + - ]: 544768 : if (!ColHidden(nCol))
1738 : : {
1739 : 544768 : SCSIZE nArrY = 0;
1740 [ + - ]: 544768 : ScDocAttrIterator aIter( pDocument, nTab, nCol, nY1, nCol, nY2 );
1741 : : SCCOL nAttrCol;
1742 : : SCROW nAttrRow1, nAttrRow2;
1743 [ + - ]: 544768 : const ScPatternAttr* pPattern = aIter.GetNext( nAttrCol, nAttrRow1, nAttrRow2 );
1744 [ + + ]: 1090786 : while ( pPattern )
1745 : : {
1746 : : const SfxPoolItem* pCondItem;
1747 [ + - ][ + + ]: 546018 : if ( pPattern->GetItemSet().GetItemState( ATTR_CONDITIONAL, true, &pCondItem )
1748 : : == SFX_ITEM_SET )
1749 : : {
1750 : : // alle Formate durchgehen, damit die Zellen nicht einzeln
1751 : : // angeschaut werden muessen
1752 : :
1753 : 6169 : sal_uLong nIndex = ((const SfxUInt32Item*)pCondItem)->GetValue();
1754 [ + - ]: 6169 : ScStyleSheetPool* pStylePool = pDocument->GetStyleSheetPool();
1755 [ + - ][ + - ]: 6169 : if (mpCondFormatList && pStylePool && nIndex)
[ + - ][ + - ]
1756 : : {
1757 [ + - ]: 6169 : const ScConditionalFormat* pFormat = mpCondFormatList->GetFormat(nIndex);
1758 [ + - ]: 6169 : if ( pFormat )
1759 : : {
1760 [ + - ]: 6169 : size_t nEntryCount = pFormat->size();
1761 [ + + ]: 10265 : for (size_t nEntry=0; nEntry<nEntryCount; nEntry++)
1762 : : {
1763 [ + - ]: 4096 : const ScFormatEntry* pEntry = pFormat->GetEntry(nEntry);
1764 [ + - ][ - + ]: 4096 : if(pEntry->GetType() != condformat::CONDITION)
1765 : 0 : continue;
1766 : :
1767 [ + - ]: 4096 : String aStyleName = static_cast<const ScCondFormatEntry*>(pEntry)->GetStyle();
1768 [ + - ]: 4096 : if (aStyleName.Len())
1769 : : {
1770 : : SfxStyleSheetBase* pStyleSheet =
1771 [ + - ]: 4096 : pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
1772 [ + - ]: 4096 : if ( pStyleSheet )
1773 : : {
1774 : : FillMaxRot( pRowInfo, nArrCount, nX1, nX2,
1775 : : nCol, nAttrRow1, nAttrRow2,
1776 [ + - ][ + - ]: 4096 : nArrY, pPattern, &pStyleSheet->GetItemSet() );
1777 : : // nArrY nicht veraendern
1778 : : }
1779 : : }
1780 [ + - ]: 4096 : }
1781 : : }
1782 : : }
1783 : : }
1784 : :
1785 : : nArrY = FillMaxRot( pRowInfo, nArrCount, nX1, nX2,
1786 : : nCol, nAttrRow1, nAttrRow2,
1787 [ + - ]: 546018 : nArrY, pPattern, NULL );
1788 : :
1789 [ + - ]: 546018 : pPattern = aIter.GetNext( nAttrCol, nAttrRow1, nAttrRow2 );
1790 [ + - ]: 544768 : }
1791 : : }
1792 : : }
1793 : : }
1794 : :
1795 : 5043 : bool ScTable::HasBlockMatrixFragment( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const
1796 : : {
1797 : : // nix:0, mitte:1, unten:2, links:4, oben:8, rechts:16, offen:32
1798 : : sal_uInt16 nEdges;
1799 : :
1800 [ + + ]: 5043 : if ( nCol1 == nCol2 )
1801 : : { // linke und rechte Spalte
1802 : 4261 : const sal_uInt16 n = 4 | 16;
1803 : 4261 : nEdges = aCol[nCol1].GetBlockMatrixEdges( nRow1, nRow2, n );
1804 : : // nicht (4 und 16) oder 1 oder 32
1805 [ + + ][ - + ]: 4261 : if ( nEdges && (((nEdges & n) != n) || (nEdges & 33)) )
[ + + ]
1806 : 6 : return true; // linke oder rechte Kante fehlt oder offen
1807 : : }
1808 : : else
1809 : : { // linke Spalte
1810 : 782 : nEdges = aCol[nCol1].GetBlockMatrixEdges( nRow1, nRow2, 4 );
1811 : : // nicht 4 oder 1 oder 32
1812 [ # # ][ # # ]: 782 : if ( nEdges && (((nEdges & 4) != 4) || (nEdges & 33)) )
[ - + ]
1813 : 0 : return true; // linke Kante fehlt oder offen
1814 : : // rechte Spalte
1815 : 782 : nEdges = aCol[nCol2].GetBlockMatrixEdges( nRow1, nRow2, 16 );
1816 : : // nicht 16 oder 1 oder 32
1817 [ # # ][ # # ]: 782 : if ( nEdges && (((nEdges & 16) != 16) || (nEdges & 33)) )
[ - + ]
1818 : 0 : return true; // rechte Kante fehlt oder offen
1819 : : }
1820 : :
1821 [ + + ]: 5037 : if ( nRow1 == nRow2 )
1822 : : { // obere und untere Zeile
1823 : 4196 : bool bOpen = false;
1824 : 4196 : const sal_uInt16 n = 2 | 8;
1825 [ + + ]: 8401 : for ( SCCOL i=nCol1; i<=nCol2; i++)
1826 : : {
1827 : 4205 : nEdges = aCol[i].GetBlockMatrixEdges( nRow1, nRow1, n );
1828 [ - + ]: 4205 : if ( nEdges )
1829 : : {
1830 [ # # ]: 0 : if ( (nEdges & n) != n )
1831 : 0 : return true; // obere oder untere Kante fehlt
1832 [ # # ]: 0 : if ( nEdges & 4 )
1833 : 0 : bOpen = true; // linke Kante oeffnet, weitersehen
1834 [ # # ]: 0 : else if ( !bOpen )
1835 : 0 : return true; // es gibt was, was nicht geoeffnet wurde
1836 [ # # ]: 0 : if ( nEdges & 16 )
1837 : 0 : bOpen = false; // rechte Kante schliesst
1838 : : }
1839 : : }
1840 [ - + ]: 4196 : if ( bOpen )
1841 : 0 : return true; // es geht noch weiter
1842 : : }
1843 : : else
1844 : : {
1845 : : sal_uInt16 j, n;
1846 : : SCROW nR;
1847 : : // erst obere Zeile, dann untere Zeile
1848 [ + + ]: 2523 : for ( j=0, nR=nRow1, n=8; j<2; j++, nR=nRow2, n=2 )
1849 : : {
1850 : 1682 : bool bOpen = false;
1851 [ + + ]: 343598 : for ( SCCOL i=nCol1; i<=nCol2; i++)
1852 : : {
1853 : 341916 : nEdges = aCol[i].GetBlockMatrixEdges( nR, nR, n );
1854 [ + + ]: 341916 : if ( nEdges )
1855 : : {
1856 : : // in oberere Zeile keine obere Kante bzw.
1857 : : // in unterer Zeile keine untere Kante
1858 [ - + ]: 2 : if ( (nEdges & n) != n )
1859 : 0 : return true;
1860 [ + - ]: 2 : if ( nEdges & 4 )
1861 : 2 : bOpen = true; // linke Kante oeffnet, weitersehen
1862 [ # # ]: 0 : else if ( !bOpen )
1863 : 0 : return true; // es gibt was, was nicht geoeffnet wurde
1864 [ + - ]: 2 : if ( nEdges & 16 )
1865 : 2 : bOpen = false; // rechte Kante schliesst
1866 : : }
1867 : : }
1868 [ - + ]: 1682 : if ( bOpen )
1869 : 0 : return true; // es geht noch weiter
1870 : : }
1871 : : }
1872 : 5043 : return false;
1873 : : }
1874 : :
1875 : :
1876 : 55 : bool ScTable::HasSelectionMatrixFragment( const ScMarkData& rMark ) const
1877 : : {
1878 : 55 : bool bFound = false;
1879 [ + + ][ + - ]: 56375 : for (SCCOL i=0; i<=MAXCOL && !bFound; i++)
[ + + ]
1880 : 56320 : bFound |= aCol[i].HasSelectionMatrixFragment(rMark);
1881 : 55 : return bFound;
1882 : : }
1883 : :
1884 : :
1885 : 5039 : bool ScTable::IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
1886 : : SCROW nRow2, bool* pOnlyNotBecauseOfMatrix /* = NULL */ ) const
1887 : : {
1888 [ - + ]: 5039 : if ( !ValidColRow( nCol2, nRow2 ) )
1889 : : {
1890 : : OSL_FAIL("IsBlockEditable: invalid column or row");
1891 [ # # ]: 0 : if (pOnlyNotBecauseOfMatrix)
1892 : 0 : *pOnlyNotBecauseOfMatrix = false;
1893 : 0 : return false;
1894 : : }
1895 : :
1896 : 5039 : bool bIsEditable = true;
1897 [ - + ]: 5039 : if ( nLockCount )
1898 : 0 : bIsEditable = false;
1899 [ - + ][ # # ]: 5039 : else if ( IsProtected() && !pDocument->IsScenario(nTab) )
[ - + ]
1900 : : {
1901 [ # # ]: 0 : if((bIsEditable = !HasAttrib( nCol1, nRow1, nCol2, nRow2, HASATTR_PROTECTED )) != false)
1902 : : {
1903 : : // If Sheet is protected and cells are not protected then
1904 : : // check the active scenario protect flag if this range is
1905 : : // on the active scenario range. Note the 'copy back' must also
1906 : : // be set to apply protection.
1907 : 0 : sal_uInt16 nScenTab = nTab+1;
1908 [ # # ]: 0 : while(pDocument->IsScenario(nScenTab))
1909 : : {
1910 : 0 : ScRange aEditRange(nCol1, nRow1, nScenTab, nCol2, nRow2, nScenTab);
1911 [ # # ][ # # ]: 0 : if(pDocument->IsActiveScenario(nScenTab) && pDocument->HasScenarioRange(nScenTab, aEditRange))
[ # # ][ # # ]
[ # # ]
1912 : : {
1913 : : sal_uInt16 nFlags;
1914 [ # # ]: 0 : pDocument->GetScenarioFlags(nScenTab,nFlags);
1915 [ # # ][ # # ]: 0 : bIsEditable = !((nFlags & SC_SCENARIO_PROTECT) && (nFlags & SC_SCENARIO_TWOWAY));
1916 : : break;
1917 : : }
1918 : 0 : nScenTab++;
1919 : : }
1920 : : }
1921 : : }
1922 [ - + ]: 5039 : else if (pDocument->IsScenario(nTab))
1923 : : {
1924 : : // Determine if the preceding sheet is protected
1925 : 0 : SCTAB nActualTab = nTab;
1926 [ # # ]: 0 : do
1927 : : {
1928 : 0 : nActualTab--;
1929 : : }
1930 : 0 : while(pDocument->IsScenario(nActualTab));
1931 : :
1932 [ # # ]: 0 : if(pDocument->IsTabProtected(nActualTab))
1933 : : {
1934 : 0 : ScRange aEditRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab);
1935 [ # # ][ # # ]: 0 : if(pDocument->HasScenarioRange(nTab, aEditRange))
1936 : : {
1937 : : sal_uInt16 nFlags;
1938 [ # # ]: 0 : pDocument->GetScenarioFlags(nTab,nFlags);
1939 : 0 : bIsEditable = !(nFlags & SC_SCENARIO_PROTECT);
1940 : : }
1941 : : }
1942 : : }
1943 [ + - ]: 5039 : if ( bIsEditable )
1944 : : {
1945 [ + + ]: 5039 : if ( HasBlockMatrixFragment( nCol1, nRow1, nCol2, nRow2 ) )
1946 : : {
1947 : 6 : bIsEditable = false;
1948 [ + - ]: 6 : if ( pOnlyNotBecauseOfMatrix )
1949 : 6 : *pOnlyNotBecauseOfMatrix = true;
1950 : : }
1951 [ + + ]: 5033 : else if ( pOnlyNotBecauseOfMatrix )
1952 : 4987 : *pOnlyNotBecauseOfMatrix = false;
1953 : : }
1954 [ # # ]: 0 : else if ( pOnlyNotBecauseOfMatrix )
1955 : 0 : *pOnlyNotBecauseOfMatrix = false;
1956 : 5039 : return bIsEditable;
1957 : : }
1958 : :
1959 : :
1960 : 55 : bool ScTable::IsSelectionEditable( const ScMarkData& rMark,
1961 : : bool* pOnlyNotBecauseOfMatrix /* = NULL */ ) const
1962 : : {
1963 : 55 : bool bIsEditable = true;
1964 [ - + ]: 55 : if ( nLockCount )
1965 : 0 : bIsEditable = false;
1966 [ - + ][ # # ]: 55 : else if ( IsProtected() && !pDocument->IsScenario(nTab) )
[ - + ]
1967 : : {
1968 [ # # ]: 0 : if((bIsEditable = !HasAttribSelection( rMark, HASATTR_PROTECTED )) != false)
1969 : : {
1970 : : // If Sheet is protected and cells are not protected then
1971 : : // check the active scenario protect flag if this area is
1972 : : // in the active scenario range.
1973 [ # # ]: 0 : ScRangeList aRanges;
1974 [ # # ]: 0 : rMark.FillRangeListWithMarks( &aRanges, false );
1975 : 0 : SCTAB nScenTab = nTab+1;
1976 [ # # ][ # # ]: 0 : while(pDocument->IsScenario(nScenTab) && bIsEditable)
[ # # ][ # # ]
1977 : : {
1978 [ # # ][ # # ]: 0 : if(pDocument->IsActiveScenario(nScenTab))
1979 : : {
1980 [ # # ][ # # ]: 0 : for (size_t i=0, nRange = aRanges.size(); (i < nRange) && bIsEditable; i++ )
[ # # ][ # # ]
1981 : : {
1982 [ # # ]: 0 : ScRange aRange = *aRanges[ i ];
1983 [ # # ][ # # ]: 0 : if(pDocument->HasScenarioRange(nScenTab, aRange))
1984 : : {
1985 : : sal_uInt16 nFlags;
1986 [ # # ]: 0 : pDocument->GetScenarioFlags(nScenTab,nFlags);
1987 [ # # ][ # # ]: 0 : bIsEditable = !((nFlags & SC_SCENARIO_PROTECT) && (nFlags & SC_SCENARIO_TWOWAY));
1988 : : }
1989 : : }
1990 : : }
1991 : 0 : nScenTab++;
1992 [ # # ]: 0 : }
1993 : : }
1994 : : }
1995 [ - + ]: 55 : else if (pDocument->IsScenario(nTab))
1996 : : {
1997 : : // Determine if the preceding sheet is protected
1998 : 0 : SCTAB nActualTab = nTab;
1999 [ # # ]: 0 : do
2000 : : {
2001 : 0 : nActualTab--;
2002 : : }
2003 : 0 : while(pDocument->IsScenario(nActualTab));
2004 : :
2005 [ # # ]: 0 : if(pDocument->IsTabProtected(nActualTab))
2006 : : {
2007 [ # # ]: 0 : ScRangeList aRanges;
2008 [ # # ]: 0 : rMark.FillRangeListWithMarks( &aRanges, false );
2009 [ # # ][ # # ]: 0 : for (size_t i = 0, nRange = aRanges.size(); (i < nRange) && bIsEditable; i++)
[ # # ][ # # ]
2010 : : {
2011 [ # # ]: 0 : ScRange aRange = *aRanges[ i ];
2012 [ # # ][ # # ]: 0 : if(pDocument->HasScenarioRange(nTab, aRange))
2013 : : {
2014 : : sal_uInt16 nFlags;
2015 [ # # ]: 0 : pDocument->GetScenarioFlags(nTab,nFlags);
2016 : 0 : bIsEditable = !(nFlags & SC_SCENARIO_PROTECT);
2017 : : }
2018 [ # # ]: 0 : }
2019 : : }
2020 : : }
2021 [ + - ]: 55 : if ( bIsEditable )
2022 : : {
2023 [ - + ]: 55 : if ( HasSelectionMatrixFragment( rMark ) )
2024 : : {
2025 : 0 : bIsEditable = false;
2026 [ # # ]: 0 : if ( pOnlyNotBecauseOfMatrix )
2027 : 0 : *pOnlyNotBecauseOfMatrix = true;
2028 : : }
2029 [ + - ]: 55 : else if ( pOnlyNotBecauseOfMatrix )
2030 : 55 : *pOnlyNotBecauseOfMatrix = false;
2031 : : }
2032 [ # # ]: 0 : else if ( pOnlyNotBecauseOfMatrix )
2033 : 0 : *pOnlyNotBecauseOfMatrix = false;
2034 : 55 : return bIsEditable;
2035 : : }
2036 : :
2037 : :
2038 : :
2039 : 0 : void ScTable::LockTable()
2040 : : {
2041 : 0 : ++nLockCount;
2042 : 0 : }
2043 : :
2044 : :
2045 : 0 : void ScTable::UnlockTable()
2046 : : {
2047 [ # # ]: 0 : if (nLockCount)
2048 : 0 : --nLockCount;
2049 : : else
2050 : : {
2051 : : OSL_FAIL("UnlockTable ohne LockTable");
2052 : : }
2053 : 0 : }
2054 : :
2055 : :
2056 : 133 : void ScTable::MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const
2057 : : {
2058 [ + + ]: 136325 : for (SCCOL i=0; i<=MAXCOL; i++)
2059 : 136192 : aCol[i].MergeSelectionPattern( rState, rMark, bDeep );
2060 : 133 : }
2061 : :
2062 : :
2063 : 7170 : void ScTable::MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
2064 : : SCCOL nCol2, SCROW nRow2, bool bDeep ) const
2065 : : {
2066 [ + + ]: 73603 : for (SCCOL i=nCol1; i<=nCol2; i++)
2067 : 66433 : aCol[i].MergePatternArea( rState, nRow1, nRow2, bDeep );
2068 : 7170 : }
2069 : :
2070 : :
2071 : 50 : void ScTable::MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags,
2072 : : SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const
2073 : : {
2074 [ + - ][ + - ]: 50 : if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
[ + - ]
2075 : : {
2076 : 50 : PutInOrder(nStartCol, nEndCol);
2077 : 50 : PutInOrder(nStartRow, nEndRow);
2078 [ + + ]: 208 : for (SCCOL i=nStartCol; i<=nEndCol; i++)
2079 : 158 : aCol[i].MergeBlockFrame( pLineOuter, pLineInner, rFlags,
2080 : 158 : nStartRow, nEndRow, (i==nStartCol), nEndCol-i );
2081 : : }
2082 : 50 : }
2083 : :
2084 : :
2085 : 1602 : void ScTable::ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
2086 : : SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
2087 : : {
2088 [ + - ][ + - ]: 1602 : if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
[ + - ]
2089 : : {
2090 : 1602 : PutInOrder(nStartCol, nEndCol);
2091 : 1602 : PutInOrder(nStartRow, nEndRow);
2092 [ + + ]: 4732 : for (SCCOL i=nStartCol; i<=nEndCol; i++)
2093 : 3130 : aCol[i].ApplyBlockFrame( pLineOuter, pLineInner,
2094 : 3130 : nStartRow, nEndRow, (i==nStartCol), nEndCol-i );
2095 : : }
2096 : 1602 : }
2097 : :
2098 : :
2099 : 27 : void ScTable::ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr )
2100 : : {
2101 [ + - ]: 27 : if (ValidColRow(nCol,nRow))
2102 : 27 : aCol[nCol].ApplyPattern( nRow, rAttr );
2103 : 27 : }
2104 : :
2105 : :
2106 : 1163 : void ScTable::ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2107 : : const ScPatternAttr& rAttr, ScEditDataArray* pDataArray )
2108 : : {
2109 [ + - ][ + - ]: 1163 : if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
[ + - ]
2110 : : {
2111 : 1163 : PutInOrder(nStartCol, nEndCol);
2112 : 1163 : PutInOrder(nStartRow, nEndRow);
2113 [ + + ]: 51318 : for (SCCOL i = nStartCol; i <= nEndCol; i++)
2114 : 50155 : aCol[i].ApplyPatternArea(nStartRow, nEndRow, rAttr, pDataArray);
2115 : : }
2116 : 1163 : }
2117 : :
2118 : 24940 : bool ScTable::SetAttrEntries(SCCOL nCol, ScAttrEntry* pData, SCSIZE nSize)
2119 : : {
2120 [ - + ]: 24940 : if (!ValidCol(nCol))
2121 : 0 : return false;
2122 : :
2123 : 24940 : return aCol[nCol].SetAttrEntries(pData, nSize);
2124 : : }
2125 : :
2126 : 0 : void ScTable::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
2127 : : const ScPatternAttr& rPattern, short nNewType )
2128 : : {
2129 : 0 : SCCOL nEndCol = rRange.aEnd.Col();
2130 [ # # ]: 0 : for ( SCCOL nCol = rRange.aStart.Col(); nCol <= nEndCol; nCol++ )
2131 : : {
2132 : 0 : aCol[nCol].ApplyPatternIfNumberformatIncompatible( rRange, rPattern, nNewType );
2133 : : }
2134 : 0 : }
2135 : :
2136 : :
2137 : :
2138 : 5 : void ScTable::ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle )
2139 : : {
2140 [ + - ]: 5 : if (ValidColRow(nCol,nRow))
2141 : 5 : aCol[nCol].ApplyStyle( nRow, rStyle );
2142 : 5 : }
2143 : :
2144 : :
2145 : 2386 : void ScTable::ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle )
2146 : : {
2147 [ + - ][ + - ]: 2386 : if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
[ + - ]
2148 : : {
2149 : 2386 : PutInOrder(nStartCol, nEndCol);
2150 : 2386 : PutInOrder(nStartRow, nEndRow);
2151 [ + + ]: 7931 : for (SCCOL i = nStartCol; i <= nEndCol; i++)
2152 : 5545 : aCol[i].ApplyStyleArea(nStartRow, nEndRow, rStyle);
2153 : : }
2154 : 2386 : }
2155 : :
2156 : :
2157 : 196 : void ScTable::ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark)
2158 : : {
2159 [ + + ]: 200900 : for (SCCOL i=0; i<=MAXCOL; i++)
2160 : 200704 : aCol[i].ApplySelectionStyle( rStyle, rMark );
2161 : 196 : }
2162 : :
2163 : :
2164 : 0 : void ScTable::ApplySelectionLineStyle( const ScMarkData& rMark,
2165 : : const ::editeng::SvxBorderLine* pLine, bool bColorOnly )
2166 : : {
2167 [ # # ][ # # ]: 0 : if ( bColorOnly && !pLine )
2168 : 0 : return;
2169 : :
2170 [ # # ]: 0 : for (SCCOL i=0; i<=MAXCOL; i++)
2171 : 0 : aCol[i].ApplySelectionLineStyle( rMark, pLine, bColorOnly );
2172 : : }
2173 : :
2174 : :
2175 : 112 : const ScStyleSheet* ScTable::GetStyle( SCCOL nCol, SCROW nRow ) const
2176 : : {
2177 [ + - ]: 112 : if (ValidColRow(nCol, nRow))
2178 : 112 : return aCol[nCol].GetStyle(nRow);
2179 : : else
2180 : 112 : return NULL;
2181 : : }
2182 : :
2183 : :
2184 : 8 : const ScStyleSheet* ScTable::GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const
2185 : : {
2186 : 8 : rFound = false;
2187 : :
2188 : 8 : bool bEqual = true;
2189 : : bool bColFound;
2190 : :
2191 : 8 : const ScStyleSheet* pStyle = NULL;
2192 : : const ScStyleSheet* pNewStyle;
2193 : :
2194 [ + + ][ + - ]: 8200 : for (SCCOL i=0; i<=MAXCOL && bEqual; i++)
[ + + ]
2195 [ + - ][ + + ]: 8192 : if (rMark.HasMultiMarks(i))
2196 : : {
2197 [ + - ]: 40 : pNewStyle = aCol[i].GetSelectionStyle( rMark, bColFound );
2198 [ + - ]: 40 : if (bColFound)
2199 : : {
2200 : 40 : rFound = true;
2201 [ + - ][ + + ]: 40 : if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) )
[ - + ]
2202 : 0 : bEqual = false; // unterschiedliche
2203 : 40 : pStyle = pNewStyle;
2204 : : }
2205 : : }
2206 : :
2207 [ + - ]: 8 : return bEqual ? pStyle : NULL;
2208 : : }
2209 : :
2210 : :
2211 : 60 : const ScStyleSheet* ScTable::GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1,
2212 : : SCCOL nCol2, SCROW nRow2 ) const
2213 : : {
2214 : 60 : rFound = false;
2215 : :
2216 : 60 : bool bEqual = true;
2217 : : bool bColFound;
2218 : :
2219 : 60 : const ScStyleSheet* pStyle = NULL;
2220 : : const ScStyleSheet* pNewStyle;
2221 : :
2222 [ + + ][ + - ]: 8400 : for (SCCOL i=nCol1; i<=nCol2 && bEqual; i++)
[ + + ]
2223 : : {
2224 [ + - ]: 8340 : pNewStyle = aCol[i].GetAreaStyle(bColFound, nRow1, nRow2);
2225 [ + - ]: 8340 : if (bColFound)
2226 : : {
2227 : 8340 : rFound = true;
2228 [ + - ][ + + ]: 8340 : if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) )
[ - + ]
2229 : 0 : bEqual = false; // unterschiedliche
2230 : 8340 : pStyle = pNewStyle;
2231 : : }
2232 : : }
2233 : :
2234 [ + - ]: 60 : return bEqual ? pStyle : NULL;
2235 : : }
2236 : :
2237 : :
2238 : 0 : bool ScTable::IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const
2239 : : {
2240 : 0 : bool bIsUsed = false;
2241 : :
2242 [ # # ]: 0 : for ( SCCOL i=0; i<=MAXCOL; i++ )
2243 : : {
2244 [ # # ]: 0 : if ( aCol[i].IsStyleSheetUsed( rStyle, bGatherAllStyles ) )
2245 : : {
2246 [ # # ]: 0 : if ( !bGatherAllStyles )
2247 : 0 : return true;
2248 : 0 : bIsUsed = true;
2249 : : }
2250 : : }
2251 : :
2252 : 0 : return bIsUsed;
2253 : : }
2254 : :
2255 : :
2256 : 5219 : void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
2257 : : OutputDevice* pDev,
2258 : : double nPPTX, double nPPTY,
2259 : : const Fraction& rZoomX, const Fraction& rZoomY )
2260 : : {
2261 [ + - ]: 5219 : ScFlatBoolRowSegments aUsedRows;
2262 [ + + ]: 5349475 : for (SCCOL i = 0; i <= MAXCOL; ++i)
2263 [ + - ]: 5344256 : aCol[i].FindStyleSheet(pStyleSheet, aUsedRows, bRemoved);
2264 : :
2265 : 5219 : SCROW nRow = 0;
2266 [ + + ]: 10438 : while (nRow <= MAXROW)
2267 : : {
2268 : : ScFlatBoolRowSegments::RangeData aData;
2269 [ + - ][ + - ]: 5219 : if (!aUsedRows.getRangeData(nRow, aData))
2270 : : // search failed!
2271 : 5219 : return;
2272 : :
2273 : 5219 : SCROW nEndRow = aData.mnRow2;
2274 [ + + ]: 5219 : if (aData.mbValue)
2275 [ + - ]: 3180 : SetOptimalHeight(nRow, nEndRow, 0, pDev, nPPTX, nPPTY, rZoomX, rZoomY, false);
2276 : :
2277 : 5219 : nRow = nEndRow + 1;
2278 [ + - ][ + - ]: 5219 : }
2279 : : }
2280 : :
2281 : :
2282 : 734 : bool ScTable::ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2283 : : sal_Int16 nFlags )
2284 : : {
2285 : 734 : bool bChanged = false;
2286 [ + - ][ + - ]: 734 : if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
[ + - ]
2287 [ + + ]: 2156 : for (SCCOL i = nStartCol; i <= nEndCol; i++)
2288 : 1422 : bChanged |= aCol[i].ApplyFlags(nStartRow, nEndRow, nFlags);
2289 : 734 : return bChanged;
2290 : : }
2291 : :
2292 : :
2293 : 259 : bool ScTable::RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2294 : : sal_Int16 nFlags )
2295 : : {
2296 : 259 : bool bChanged = false;
2297 [ + - ][ + - ]: 259 : if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
[ + - ]
2298 [ + + ]: 12374 : for (SCCOL i = nStartCol; i <= nEndCol; i++)
2299 : 12115 : bChanged |= aCol[i].RemoveFlags(nStartRow, nEndRow, nFlags);
2300 : 259 : return bChanged;
2301 : : }
2302 : :
2303 : :
2304 : 18 : void ScTable::SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr, bool bPutToPool )
2305 : : {
2306 [ + - ]: 18 : if (ValidColRow(nCol,nRow))
2307 : 18 : aCol[nCol].SetPattern( nRow, rAttr, bPutToPool );
2308 : 18 : }
2309 : :
2310 : :
2311 : 742 : void ScTable::ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr )
2312 : : {
2313 [ + - ]: 742 : if (ValidColRow(nCol,nRow))
2314 : 742 : aCol[nCol].ApplyAttr( nRow, rAttr );
2315 : 742 : }
2316 : :
2317 : :
2318 : 100 : void ScTable::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark,
2319 : : ScEditDataArray* pDataArray )
2320 : : {
2321 [ + + ]: 102500 : for (SCCOL i=0; i<=MAXCOL; i++)
2322 : 102400 : aCol[i].ApplySelectionCache( pCache, rMark, pDataArray );
2323 : 100 : }
2324 : :
2325 : :
2326 : 8 : void ScTable::ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark )
2327 : : {
2328 [ + + ]: 8200 : for (SCCOL i=0; i<=MAXCOL; i++)
2329 : 8192 : aCol[i].ChangeSelectionIndent( bIncrement, rMark );
2330 : 8 : }
2331 : :
2332 : :
2333 : 0 : void ScTable::ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark )
2334 : : {
2335 [ # # ]: 0 : for (SCCOL i=0; i<=MAXCOL; i++)
2336 : 0 : aCol[i].ClearSelectionItems( pWhich, rMark );
2337 : 0 : }
2338 : :
2339 : :
2340 : : // Spaltenbreiten / Zeilenhoehen
2341 : :
2342 : 64089 : void ScTable::SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth )
2343 : : {
2344 [ + - ][ + - ]: 64089 : if (VALIDCOL(nCol) && pColWidth)
[ + - ]
2345 : : {
2346 [ - + ]: 64089 : if (!nNewWidth)
2347 : : {
2348 : 0 : nNewWidth = STD_COL_WIDTH;
2349 : : }
2350 : :
2351 [ + + ]: 64089 : if ( nNewWidth != pColWidth[nCol] )
2352 : : {
2353 : 63922 : IncRecalcLevel();
2354 : 63922 : InitializeNoteCaptions();
2355 : 63922 : pColWidth[nCol] = nNewWidth;
2356 : 63922 : DecRecalcLevel();
2357 : :
2358 : 63922 : InvalidatePageBreaks();
2359 : : }
2360 : : }
2361 : : else
2362 : : {
2363 : : OSL_FAIL("Falsche Spaltennummer oder keine Breiten");
2364 : : }
2365 : 64089 : }
2366 : :
2367 : 168960 : void ScTable::SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth )
2368 : : {
2369 [ + - ][ - + ]: 168960 : if (!VALIDCOL(nCol) || !pColWidth)
[ - + ]
2370 : 168960 : return;
2371 : :
2372 [ - + ]: 168960 : if (!nNewWidth)
2373 : 0 : nNewWidth = STD_COL_WIDTH;
2374 : :
2375 [ + + ]: 168960 : if (nNewWidth != pColWidth[nCol])
2376 : 159759 : pColWidth[nCol] = nNewWidth;
2377 : : }
2378 : :
2379 : 0 : void ScTable::SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight )
2380 : : {
2381 [ # # ][ # # ]: 0 : if (VALIDROW(nRow) && mpRowHeights)
[ # # ]
2382 : : {
2383 [ # # ]: 0 : if (!nNewHeight)
2384 : : {
2385 : : OSL_FAIL("Zeilenhoehe 0 in SetRowHeight");
2386 : 0 : nNewHeight = ScGlobal::nStdRowHeight;
2387 : : }
2388 : :
2389 : 0 : sal_uInt16 nOldHeight = mpRowHeights->getValue(nRow);
2390 [ # # ]: 0 : if ( nNewHeight != nOldHeight )
2391 : : {
2392 : 0 : mpRowHeights->setValue(nRow, nRow, nNewHeight);
2393 : 0 : InvalidatePageBreaks();
2394 : : }
2395 : : }
2396 : : else
2397 : : {
2398 : : OSL_FAIL("Falsche Zeilennummer oder keine Hoehen");
2399 : : }
2400 : 0 : }
2401 : :
2402 : : namespace {
2403 : :
2404 : : /**
2405 : : * Check if the new pixel size is different from the old size between
2406 : : * specified ranges.
2407 : : */
2408 : 2679 : bool lcl_pixelSizeChanged(
2409 : : ScFlatUInt16RowSegments& rRowHeights, SCROW nStartRow, SCROW nEndRow,
2410 : : sal_uInt16 nNewHeight, double nPPTY)
2411 : : {
2412 : 2679 : long nNewPix = static_cast<long>(nNewHeight * nPPTY);
2413 : :
2414 [ + - ]: 2679 : ScFlatUInt16RowSegments::ForwardIterator aFwdIter(rRowHeights);
2415 [ + + ]: 4897 : for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
2416 : : {
2417 : : sal_uInt16 nHeight;
2418 [ + - ][ + - ]: 2694 : if (!aFwdIter.getValue(nRow, nHeight))
2419 : : break;
2420 : :
2421 [ + + ]: 2694 : if (nHeight != nNewHeight)
2422 : : {
2423 : 495 : bool bChanged = (nNewPix != static_cast<long>(nHeight * nPPTY));
2424 [ + + ]: 495 : if (bChanged)
2425 : 476 : return true;
2426 : : }
2427 : :
2428 : : // Skip ahead to the last position of the current range.
2429 [ + - ]: 2218 : nRow = aFwdIter.getLastPos();
2430 : : }
2431 : 2679 : return false;
2432 : : }
2433 : :
2434 : : }
2435 : :
2436 : 2679 : bool ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
2437 : : double /* nPPTX */, double nPPTY )
2438 : : {
2439 : 2679 : bool bChanged = false;
2440 [ + - ][ + - ]: 2679 : if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && mpRowHeights)
[ + - ][ + - ]
2441 : : {
2442 [ - + ]: 2679 : if (!nNewHeight)
2443 : : {
2444 : : OSL_FAIL("Zeilenhoehe 0 in SetRowHeight");
2445 : 0 : nNewHeight = ScGlobal::nStdRowHeight;
2446 : : }
2447 : :
2448 : 2679 : bool bSingle = false; // true = process every row for its own
2449 : 2679 : ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
2450 [ + + ]: 2679 : if (pDrawLayer)
2451 [ - + ]: 1755 : if (pDrawLayer->HasObjectsInRows( nTab, nStartRow, nEndRow ))
2452 : 0 : bSingle = true;
2453 : :
2454 [ - + ]: 2679 : if (bSingle)
2455 : : {
2456 : : ScFlatUInt16RowSegments::RangeData aData;
2457 [ # # ]: 0 : mpRowHeights->getRangeData(nStartRow, aData);
2458 [ # # ][ # # ]: 0 : if (nNewHeight == aData.mnValue && nEndRow <= aData.mnRow2)
2459 : 0 : bSingle = false; // no difference in this range
2460 : : }
2461 [ - + ]: 2679 : if (bSingle)
2462 : : {
2463 [ # # ]: 0 : if (nEndRow-nStartRow < 20)
2464 : : {
2465 [ # # ]: 0 : if (!bChanged)
2466 : 0 : bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY);
2467 : :
2468 : 0 : mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight);
2469 : : }
2470 : : else
2471 : : {
2472 : 0 : SCROW nMid = (nStartRow+nEndRow) / 2;
2473 [ # # ]: 0 : if (SetRowHeightRange( nStartRow, nMid, nNewHeight, 1.0, 1.0 ))
2474 : 0 : bChanged = true;
2475 [ # # ]: 0 : if (SetRowHeightRange( nMid+1, nEndRow, nNewHeight, 1.0, 1.0 ))
2476 : 0 : bChanged = true;
2477 : : }
2478 : : }
2479 : : else
2480 : : {
2481 [ + - ]: 2679 : if (!bChanged)
2482 : 2679 : bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY);
2483 : :
2484 : 2679 : mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight);
2485 : : }
2486 : :
2487 [ + + ]: 2679 : if (bChanged)
2488 : 476 : InvalidatePageBreaks();
2489 : : }
2490 : : else
2491 : : {
2492 : : OSL_FAIL("Falsche Zeilennummer oder keine Hoehen");
2493 : : }
2494 : :
2495 : 2679 : return bChanged;
2496 : : }
2497 : :
2498 : 4894 : void ScTable::SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight )
2499 : : {
2500 [ + - ][ + - ]: 4894 : if (!ValidRow(nStartRow) || !ValidRow(nEndRow) || !mpRowHeights)
[ - + ][ - + ]
2501 : 4894 : return;
2502 : :
2503 [ - + ]: 4894 : if (!nNewHeight)
2504 : 0 : nNewHeight = ScGlobal::nStdRowHeight;
2505 : :
2506 : 4894 : mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight);
2507 : : }
2508 : :
2509 : 242 : void ScTable::SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual )
2510 : : {
2511 [ + - ][ + - ]: 242 : if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowFlags)
[ + - ][ + - ]
2512 : : {
2513 [ + - ]: 242 : if (bManual)
2514 : 242 : pRowFlags->OrValue( nStartRow, nEndRow, CR_MANUALSIZE);
2515 : : else
2516 [ # # ]: 0 : pRowFlags->AndValue( nStartRow, nEndRow, sal::static_int_cast<sal_uInt8>(~CR_MANUALSIZE));
2517 : : }
2518 : : else
2519 : : {
2520 : : OSL_FAIL("Falsche Zeilennummer oder keine Zeilenflags");
2521 : : }
2522 : 242 : }
2523 : :
2524 : :
2525 : 322840 : sal_uInt16 ScTable::GetColWidth( SCCOL nCol ) const
2526 : : {
2527 : : OSL_ENSURE(VALIDCOL(nCol),"Falsche Spaltennummer");
2528 : :
2529 [ + - ][ + - ]: 322840 : if (VALIDCOL(nCol) && pColFlags && pColWidth)
[ + - ][ + - ]
2530 : : {
2531 [ + + ]: 322840 : if (ColHidden(nCol))
2532 : 3 : return 0;
2533 : : else
2534 : 322837 : return pColWidth[nCol];
2535 : : }
2536 : : else
2537 : 322840 : return (sal_uInt16) STD_COL_WIDTH;
2538 : : }
2539 : :
2540 : :
2541 : 4724 : sal_uInt16 ScTable::GetOriginalWidth( SCCOL nCol ) const // immer die eingestellte
2542 : : {
2543 : : OSL_ENSURE(VALIDCOL(nCol),"Falsche Spaltennummer");
2544 : :
2545 [ + - ][ + - ]: 4724 : if (VALIDCOL(nCol) && pColWidth)
[ + - ]
2546 : 4724 : return pColWidth[nCol];
2547 : : else
2548 : 4724 : return (sal_uInt16) STD_COL_WIDTH;
2549 : : }
2550 : :
2551 : :
2552 : 0 : sal_uInt16 ScTable::GetCommonWidth( SCCOL nEndCol ) const
2553 : : {
2554 : : // get the width that is used in the largest continuous column range (up to nEndCol)
2555 : :
2556 [ # # ]: 0 : if ( !ValidCol(nEndCol) )
2557 : : {
2558 : : OSL_FAIL("wrong column");
2559 : 0 : nEndCol = MAXCOL;
2560 : : }
2561 : :
2562 : 0 : sal_uInt16 nMaxWidth = 0;
2563 : 0 : sal_uInt16 nMaxCount = 0;
2564 : 0 : SCCOL nRangeStart = 0;
2565 [ # # ]: 0 : while ( nRangeStart <= nEndCol )
2566 : : {
2567 : : // skip hidden columns
2568 [ # # ][ # # ]: 0 : while ( nRangeStart <= nEndCol && ColHidden(nRangeStart) )
[ # # ]
2569 : 0 : ++nRangeStart;
2570 [ # # ]: 0 : if ( nRangeStart <= nEndCol )
2571 : : {
2572 : 0 : sal_uInt16 nThisCount = 0;
2573 : 0 : sal_uInt16 nThisWidth = pColWidth[nRangeStart];
2574 : 0 : SCCOL nRangeEnd = nRangeStart;
2575 [ # # ][ # # ]: 0 : while ( nRangeEnd <= nEndCol && pColWidth[nRangeEnd] == nThisWidth )
[ # # ]
2576 : : {
2577 : 0 : ++nThisCount;
2578 : 0 : ++nRangeEnd;
2579 : :
2580 : : // skip hidden columns
2581 [ # # ][ # # ]: 0 : while ( nRangeEnd <= nEndCol && ColHidden(nRangeEnd) )
[ # # ]
2582 : 0 : ++nRangeEnd;
2583 : : }
2584 : :
2585 [ # # ]: 0 : if ( nThisCount > nMaxCount )
2586 : : {
2587 : 0 : nMaxCount = nThisCount;
2588 : 0 : nMaxWidth = nThisWidth;
2589 : : }
2590 : :
2591 : 0 : nRangeStart = nRangeEnd; // next range
2592 : : }
2593 : : }
2594 : :
2595 : 0 : return nMaxWidth;
2596 : : }
2597 : :
2598 : :
2599 : 1086652 : sal_uInt16 ScTable::GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero ) const
2600 : : {
2601 : : OSL_ENSURE(VALIDROW(nRow),"Invalid row number");
2602 : :
2603 [ + - ][ + - ]: 1086652 : if (VALIDROW(nRow) && mpRowHeights)
[ + - ]
2604 : : {
2605 [ + + ][ + + ]: 1086652 : if (bHiddenAsZero && RowHidden( nRow, pStartRow, pEndRow))
[ + + ]
2606 : 819 : return 0;
2607 : : else
2608 : : {
2609 : : ScFlatUInt16RowSegments::RangeData aData;
2610 [ + - ][ - + ]: 1085833 : if (!mpRowHeights->getRangeData(nRow, aData))
2611 : : {
2612 [ # # ]: 0 : if (pStartRow)
2613 : 0 : *pStartRow = nRow;
2614 [ # # ]: 0 : if (pEndRow)
2615 : 0 : *pEndRow = nRow;
2616 : : // TODO: What should we return in case the search fails?
2617 : 0 : return 0;
2618 : : }
2619 : :
2620 : : // If bHiddenAsZero, pStartRow and pEndRow were initialized to
2621 : : // boundaries of a non-hidden segment. Assume that the previous and
2622 : : // next segment are hidden then and limit the current height
2623 : : // segment.
2624 [ - + ]: 1085833 : if (pStartRow)
2625 [ # # ][ # # ]: 0 : *pStartRow = (bHiddenAsZero ? std::max( *pStartRow, aData.mnRow1) : aData.mnRow1);
2626 [ + + ]: 1085833 : if (pEndRow)
2627 [ + + ][ + - ]: 33777 : *pEndRow = (bHiddenAsZero ? std::min( *pEndRow, aData.mnRow2) : aData.mnRow2);
2628 : 1085833 : return aData.mnValue;
2629 : : }
2630 : : }
2631 : : else
2632 : : {
2633 [ # # ]: 0 : if (pStartRow)
2634 : 0 : *pStartRow = nRow;
2635 [ # # ]: 0 : if (pEndRow)
2636 : 0 : *pEndRow = nRow;
2637 : 1086652 : return (sal_uInt16) ScGlobal::nStdRowHeight;
2638 : : }
2639 : : }
2640 : :
2641 : :
2642 : 652 : sal_uLong ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const
2643 : : {
2644 : : OSL_ENSURE(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer");
2645 : :
2646 [ + - ][ + - ]: 652 : if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && mpRowHeights)
[ + - ][ + - ]
2647 : : {
2648 : 652 : sal_uLong nHeight = 0;
2649 : 652 : SCROW nRow = nStartRow;
2650 [ + + ]: 1413 : while (nRow <= nEndRow)
2651 : : {
2652 : 761 : SCROW nLastRow = -1;
2653 [ + - ][ + + ]: 761 : if (!RowHidden(nRow, NULL, &nLastRow))
2654 : : {
2655 [ + + ]: 698 : if (nLastRow > nEndRow)
2656 : 488 : nLastRow = nEndRow;
2657 [ + - ]: 698 : nHeight += mpRowHeights->getSumValue(nRow, nLastRow);
2658 : : }
2659 : 761 : nRow = nLastRow + 1;
2660 : : }
2661 : 652 : return nHeight;
2662 : : }
2663 : : else
2664 : 652 : return (sal_uLong) ((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight);
2665 : : }
2666 : :
2667 : :
2668 : 0 : sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const
2669 : : {
2670 : : OSL_ENSURE(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer");
2671 : :
2672 [ # # ][ # # ]: 0 : if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && mpRowHeights)
[ # # ][ # # ]
2673 : : {
2674 : 0 : sal_uLong nHeight = 0;
2675 : 0 : SCROW nRow = nStartRow;
2676 [ # # ]: 0 : while (nRow <= nEndRow)
2677 : : {
2678 : 0 : SCROW nLastRow = -1;
2679 [ # # ][ # # ]: 0 : if (!RowHidden(nRow, NULL, &nLastRow))
2680 : : {
2681 [ # # ]: 0 : if (nLastRow > nEndRow)
2682 : 0 : nLastRow = nEndRow;
2683 [ # # ]: 0 : sal_uInt32 nThisHeight = mpRowHeights->getSumValue(nRow, nLastRow);
2684 : 0 : nHeight += static_cast<sal_uLong>(nThisHeight * fScale);
2685 : : }
2686 : 0 : nRow = nLastRow + 1;
2687 : : }
2688 : 0 : return nHeight;
2689 : : }
2690 : : else
2691 : 0 : return (sal_uLong) ((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight * fScale);
2692 : : }
2693 : :
2694 : :
2695 : 44973 : sal_uInt16 ScTable::GetOriginalHeight( SCROW nRow ) const // non-0 even if hidden
2696 : : {
2697 : : OSL_ENSURE(VALIDROW(nRow),"wrong row number");
2698 : :
2699 [ + - ][ + - ]: 44973 : if (VALIDROW(nRow) && mpRowHeights)
[ + - ]
2700 : 44973 : return mpRowHeights->getValue(nRow);
2701 : : else
2702 : 44973 : return (sal_uInt16) ScGlobal::nStdRowHeight;
2703 : : }
2704 : :
2705 : :
2706 : : // Spalten-/Zeilen-Flags
2707 : :
2708 : :
2709 : 32 : SCROW ScTable::GetHiddenRowCount( SCROW nRow ) const
2710 : : {
2711 [ - + ]: 32 : if (!ValidRow(nRow))
2712 : 0 : return 0;
2713 : :
2714 : 32 : SCROW nLastRow = -1;
2715 [ + - ][ + - ]: 32 : if (!RowHidden(nRow, NULL, &nLastRow) || !ValidRow(nLastRow))
[ - + ][ - + ]
2716 : 0 : return 0;
2717 : :
2718 : 32 : return nLastRow - nRow + 1;
2719 : : }
2720 : :
2721 : :
2722 : : //! ShowRows / DBShowRows zusammenfassen
2723 : :
2724 : 2442 : void ScTable::ShowCol(SCCOL nCol, bool bShow)
2725 : : {
2726 [ + - ]: 2442 : if (VALIDCOL(nCol))
2727 : : {
2728 : 2442 : bool bWasVis = !ColHidden(nCol);
2729 [ + + ]: 2442 : if (bWasVis != bShow)
2730 : : {
2731 : 3 : IncRecalcLevel();
2732 : 3 : InitializeNoteCaptions();
2733 : :
2734 : 3 : SetColHidden(nCol, nCol, !bShow);
2735 : 3 : DecRecalcLevel();
2736 : :
2737 : 3 : ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
2738 [ + - ]: 3 : if ( pCharts )
2739 [ + - ]: 3 : pCharts->SetRangeDirty(ScRange( nCol, 0, nTab, nCol, MAXROW, nTab ));
2740 : : }
2741 : : }
2742 : : else
2743 : : {
2744 : : OSL_FAIL("Falsche Spaltennummer oder keine Flags");
2745 : : }
2746 : 2442 : }
2747 : :
2748 : :
2749 : 0 : void ScTable::ShowRow(SCROW nRow, bool bShow)
2750 : : {
2751 [ # # ][ # # ]: 0 : if (VALIDROW(nRow) && pRowFlags)
[ # # ]
2752 : : {
2753 : 0 : bool bWasVis = !RowHidden(nRow);
2754 [ # # ]: 0 : if (bWasVis != bShow)
2755 : : {
2756 : 0 : SetRowHidden(nRow, nRow, !bShow);
2757 [ # # ]: 0 : if (bShow)
2758 : 0 : SetRowFiltered(nRow, nRow, false);
2759 : 0 : ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
2760 [ # # ]: 0 : if ( pCharts )
2761 [ # # ]: 0 : pCharts->SetRangeDirty(ScRange( 0, nRow, nTab, MAXCOL, nRow, nTab ));
2762 : :
2763 : 0 : InvalidatePageBreaks();
2764 : : }
2765 : : }
2766 : : else
2767 : : {
2768 : : OSL_FAIL("Falsche Zeilennummer oder keine Flags");
2769 : : }
2770 : 0 : }
2771 : :
2772 : :
2773 : 5 : void ScTable::DBShowRow(SCROW nRow, bool bShow)
2774 : : {
2775 [ + - ][ + - ]: 5 : if (VALIDROW(nRow) && pRowFlags)
[ + - ]
2776 : : {
2777 : : // Filter-Flag immer setzen, auch wenn Hidden unveraendert
2778 : 5 : bool bChanged = SetRowHidden(nRow, nRow, !bShow);
2779 : 5 : SetRowFiltered(nRow, nRow, !bShow);
2780 : :
2781 [ - + ]: 5 : if (bChanged)
2782 : : {
2783 : 0 : ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
2784 [ # # ]: 0 : if ( pCharts )
2785 [ # # ]: 0 : pCharts->SetRangeDirty(ScRange( 0, nRow, nTab, MAXCOL, nRow, nTab ));
2786 : :
2787 [ # # ]: 0 : if (pOutlineTable)
2788 : 0 : UpdateOutlineRow( nRow, nRow, bShow );
2789 : :
2790 : 0 : InvalidatePageBreaks();
2791 : : }
2792 : : }
2793 : : else
2794 : : {
2795 : : OSL_FAIL("Falsche Zeilennummer oder keine Flags");
2796 : : }
2797 : 5 : }
2798 : :
2799 : :
2800 : 40 : void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow)
2801 : : {
2802 : 40 : SCROW nStartRow = nRow1;
2803 [ + + ]: 88 : while (nStartRow <= nRow2)
2804 : : {
2805 : 48 : SCROW nEndRow = -1;
2806 [ + - ]: 48 : bool bWasVis = !RowHiddenLeaf(nStartRow, NULL, &nEndRow);
2807 [ + + ]: 48 : if (nEndRow > nRow2)
2808 : 34 : nEndRow = nRow2;
2809 : :
2810 : 48 : bool bChanged = ( bWasVis != bShow );
2811 : :
2812 [ + - ]: 48 : SetRowHidden(nStartRow, nEndRow, !bShow);
2813 [ + - ]: 48 : SetRowFiltered(nStartRow, nEndRow, !bShow);
2814 : :
2815 [ + + ]: 48 : if ( bChanged )
2816 : : {
2817 [ + - ]: 24 : ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
2818 [ + - ]: 24 : if ( pCharts )
2819 [ + - ]: 24 : pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab ));
2820 : : }
2821 : :
2822 : 48 : nStartRow = nEndRow + 1;
2823 : : }
2824 : :
2825 : : // #i12341# For Show/Hide rows, the outlines are updated separately from the outside.
2826 : : // For filtering, the changes aren't visible to the caller, so UpdateOutlineRow has
2827 : : // to be done here.
2828 [ - + ]: 40 : if (pOutlineTable)
2829 : 0 : UpdateOutlineRow( nRow1, nRow2, bShow );
2830 : 40 : }
2831 : :
2832 : :
2833 : 46 : void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow)
2834 : : {
2835 : 46 : SCROW nStartRow = nRow1;
2836 : 46 : IncRecalcLevel();
2837 : 46 : InitializeNoteCaptions();
2838 : :
2839 : : // #i116164# if there are no drawing objects within the row range, a single HeightChanged call is enough
2840 : 46 : ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
2841 [ + + ][ + + ]: 46 : bool bHasObjects = pDrawLayer && pDrawLayer->HasObjectsInRows( nTab, nRow1, nRow2 );
2842 : :
2843 [ + + ]: 92 : while (nStartRow <= nRow2)
2844 : : {
2845 : 46 : SCROW nEndRow = -1;
2846 [ + - ]: 46 : bool bWasVis = !RowHiddenLeaf(nStartRow, NULL, &nEndRow);
2847 [ + + ]: 46 : if (nEndRow > nRow2)
2848 : 39 : nEndRow = nRow2;
2849 : :
2850 : 46 : bool bChanged = ( bWasVis != bShow );
2851 : :
2852 [ + - ]: 46 : SetRowHidden(nStartRow, nEndRow, !bShow);
2853 [ + + ]: 46 : if (bShow)
2854 [ + - ]: 7 : SetRowFiltered(nStartRow, nEndRow, false);
2855 : :
2856 [ + - ]: 46 : if ( bChanged )
2857 : : {
2858 [ + - ]: 46 : ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
2859 [ + - ]: 46 : if ( pCharts )
2860 [ + - ]: 46 : pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab ));
2861 : :
2862 : 46 : InvalidatePageBreaks();
2863 : : }
2864 : :
2865 : 46 : nStartRow = nEndRow + 1;
2866 : : }
2867 : :
2868 [ + + ]: 46 : if ( !bHasObjects )
2869 : : {
2870 : : // #i116164# set the flags for the whole range at once
2871 : 37 : SetRowHidden(nRow1, nRow2, !bShow);
2872 [ + + ]: 37 : if (bShow)
2873 : 4 : SetRowFiltered(nRow1, nRow2, false);
2874 : : }
2875 : :
2876 : 46 : DecRecalcLevel();
2877 : 46 : }
2878 : :
2879 : 27 : bool ScTable::IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const
2880 : : {
2881 [ + + ]: 105 : for (SCROW i = nRowStart; i <= nRowEnd; ++i)
2882 : : {
2883 [ + + ]: 84 : if (RowHidden(i))
2884 : 6 : return true;
2885 : : }
2886 [ + + ]: 72 : for (SCCOL i = nColStart; i <= nColEnd; ++i)
2887 : : {
2888 [ - + ]: 51 : if (ColHidden(i))
2889 : 0 : return true;
2890 : : }
2891 : 27 : return false;
2892 : : }
2893 : :
2894 : 27 : bool ScTable::IsDataFiltered(const ScRange& rRange) const
2895 : : {
2896 : 27 : return IsDataFiltered(rRange.aStart.Col(), rRange.aStart.Row(),
2897 : 54 : rRange.aEnd.Col(), rRange.aEnd.Row());
2898 : : }
2899 : :
2900 : 0 : void ScTable::SetRowFlags( SCROW nRow, sal_uInt8 nNewFlags )
2901 : : {
2902 [ # # ][ # # ]: 0 : if (VALIDROW(nRow) && pRowFlags)
[ # # ]
2903 : 0 : pRowFlags->SetValue( nRow, nNewFlags);
2904 : : else
2905 : : {
2906 : : OSL_FAIL("Falsche Zeilennummer oder keine Flags");
2907 : : }
2908 : 0 : }
2909 : :
2910 : :
2911 : 24 : void ScTable::SetRowFlags( SCROW nStartRow, SCROW nEndRow, sal_uInt8 nNewFlags )
2912 : : {
2913 [ + - ][ + - ]: 24 : if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowFlags)
[ + - ][ + - ]
2914 : 24 : pRowFlags->SetValue( nStartRow, nEndRow, nNewFlags);
2915 : : else
2916 : : {
2917 : : OSL_FAIL("Falsche Zeilennummer(n) oder keine Flags");
2918 : : }
2919 : 24 : }
2920 : :
2921 : :
2922 : 8188 : sal_uInt8 ScTable::GetColFlags( SCCOL nCol ) const
2923 : : {
2924 [ + - ][ + - ]: 8188 : if (VALIDCOL(nCol) && pColFlags)
[ + - ]
2925 : 8188 : return pColFlags[nCol];
2926 : : else
2927 : 8188 : return 0;
2928 : : }
2929 : :
2930 : :
2931 : 2936 : sal_uInt8 ScTable::GetRowFlags( SCROW nRow ) const
2932 : : {
2933 [ + - ][ + - ]: 2936 : if (VALIDROW(nRow) && pRowFlags)
[ + - ]
2934 : 2936 : return pRowFlags->GetValue(nRow);
2935 : : else
2936 : 2936 : return 0;
2937 : : }
2938 : :
2939 : :
2940 : 4 : SCROW ScTable::GetLastFlaggedRow() const
2941 : : {
2942 : 4 : SCROW nLastFound = 0;
2943 [ + - ]: 4 : if (pRowFlags)
2944 : : {
2945 [ + - ]: 4 : SCROW nRow = pRowFlags->GetLastAnyBitAccess( 0, sal::static_int_cast<sal_uInt8>(CR_ALL) );
2946 [ - + ]: 4 : if (ValidRow(nRow))
2947 : 0 : nLastFound = nRow;
2948 : : }
2949 : :
2950 [ - + ]: 4 : if (!maRowManualBreaks.empty())
2951 [ # # ][ # # ]: 0 : nLastFound = ::std::max(nLastFound, *maRowManualBreaks.rbegin());
2952 : :
2953 [ + - ]: 4 : if (mpHiddenRows)
2954 : : {
2955 [ + - ]: 4 : SCROW nRow = mpHiddenRows->findLastNotOf(false);
2956 [ - + ]: 4 : if (ValidRow(nRow))
2957 [ # # ]: 4 : nLastFound = ::std::max(nLastFound, nRow);
2958 : : }
2959 : :
2960 [ + - ]: 4 : if (mpFilteredRows)
2961 : : {
2962 [ + - ]: 4 : SCROW nRow = mpFilteredRows->findLastNotOf(false);
2963 [ - + ]: 4 : if (ValidRow(nRow))
2964 [ # # ]: 4 : nLastFound = ::std::max(nLastFound, nRow);
2965 : : }
2966 : :
2967 : 4 : return nLastFound;
2968 : : }
2969 : :
2970 : :
2971 : 4 : SCCOL ScTable::GetLastChangedCol() const
2972 : : {
2973 [ - + ]: 4 : if ( !pColFlags )
2974 : 0 : return 0;
2975 : :
2976 : 4 : SCCOL nLastFound = 0;
2977 [ + + ]: 4096 : for (SCCOL nCol = 1; nCol <= MAXCOL; nCol++)
2978 [ + - ][ - + ]: 4092 : if ((pColFlags[nCol] & CR_ALL) || (pColWidth[nCol] != STD_COL_WIDTH))
2979 : 0 : nLastFound = nCol;
2980 : :
2981 : 4 : return nLastFound;
2982 : : }
2983 : :
2984 : :
2985 : 4 : SCROW ScTable::GetLastChangedRow() const
2986 : : {
2987 [ - + ]: 4 : if ( !pRowFlags )
2988 : 0 : return 0;
2989 : :
2990 [ + - ]: 4 : SCROW nLastFlags = GetLastFlaggedRow();
2991 : :
2992 : : // Find the last row position where the height is NOT the standard row
2993 : : // height.
2994 : : // KOHEI: Test this to make sure it does what it's supposed to.
2995 [ + - ]: 4 : SCROW nLastHeight = mpRowHeights->findLastNotOf(ScGlobal::nStdRowHeight);
2996 [ + - ]: 4 : if (!ValidRow(nLastHeight))
2997 : 4 : nLastHeight = 0;
2998 : :
2999 [ + - ]: 4 : return std::max( nLastFlags, nLastHeight);
3000 : : }
3001 : :
3002 : :
3003 : 333 : bool ScTable::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow )
3004 : : {
3005 [ - + ][ # # ]: 333 : if (pOutlineTable && pColFlags)
3006 : : {
3007 [ # # ]: 0 : ScBitMaskCompressedArray< SCCOLROW, sal_uInt8> aArray( MAXCOL, pColFlags, MAXCOLCOUNT);
3008 [ # # ][ # # ]: 0 : return pOutlineTable->GetColArray()->ManualAction( nStartCol, nEndCol, bShow, *this, true );
3009 : : }
3010 : : else
3011 : 333 : return false;
3012 : : }
3013 : :
3014 : :
3015 : 34 : bool ScTable::UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow )
3016 : : {
3017 [ - + ][ # # ]: 34 : if (pOutlineTable && pRowFlags)
3018 : 0 : return pOutlineTable->GetRowArray()->ManualAction( nStartRow, nEndRow, bShow, *this, false );
3019 : : else
3020 : 34 : return false;
3021 : : }
3022 : :
3023 : :
3024 : 5104 : void ScTable::ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 )
3025 : : {
3026 : : // Column-wise expansion
3027 : :
3028 [ + + ][ - + ]: 5104 : while (rX1 > 0 && ColHidden(rX1-1))
[ - + ]
3029 : 0 : --rX1;
3030 : :
3031 [ + - ][ - + ]: 5104 : while (rX2 < MAXCOL && ColHidden(rX2+1))
[ - + ]
3032 : 0 : ++rX2;
3033 : :
3034 : : // Row-wise expansion
3035 : :
3036 [ + + ]: 5104 : if (rY1 > 0)
3037 : : {
3038 : : ScFlatBoolRowSegments::RangeData aData;
3039 [ + - ][ + - ]: 306 : if (mpHiddenRows->getRangeData(rY1-1, aData) && aData.mbValue)
[ + + ][ + + ]
3040 : : {
3041 : 17 : SCROW nStartRow = aData.mnRow1;
3042 [ + - ]: 17 : if (ValidRow(nStartRow))
3043 : 306 : rY1 = nStartRow;
3044 : : }
3045 : : }
3046 [ + - ]: 5104 : if (rY2 < MAXROW)
3047 : : {
3048 : 5104 : SCROW nEndRow = -1;
3049 [ + - ][ + + ]: 5104 : if (RowHidden(rY2+1, NULL, &nEndRow) && ValidRow(nEndRow))
[ + - ][ + + ]
3050 : 5104 : rY2 = nEndRow;
3051 : : }
3052 : 5104 : }
3053 : :
3054 : :
3055 : 5170 : void ScTable::StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 )
3056 : : {
3057 [ + + ][ - + ]: 5170 : while ( rX2>rX1 && ColHidden(rX2) )
[ - + ]
3058 : 0 : --rX2;
3059 [ + + ][ - + ]: 5170 : while ( rX2>rX1 && ColHidden(rX1) )
[ - + ]
3060 : 0 : ++rX1;
3061 : :
3062 [ + + ]: 5170 : if (rY1 < rY2)
3063 : : {
3064 : : ScFlatBoolRowSegments::RangeData aData;
3065 [ + - ][ + - ]: 5049 : if (mpHiddenRows->getRangeData(rY2, aData) && aData.mbValue)
[ + + ][ + + ]
3066 : : {
3067 : 14 : SCROW nStartRow = aData.mnRow1;
3068 [ + - ][ + - ]: 14 : if (ValidRow(nStartRow) && nStartRow >= rY1)
[ + - ]
3069 : 5049 : rY2 = nStartRow;
3070 : : }
3071 : : }
3072 : :
3073 [ + + ]: 5170 : if (rY1 < rY2)
3074 : : {
3075 : 5049 : SCROW nEndRow = -1;
3076 [ + - ][ + + ]: 5049 : if (RowHidden(rY1, NULL, &nEndRow) && ValidRow(nEndRow) && nEndRow <= rY2)
[ + - ][ + - ]
[ + + ]
3077 : 5049 : rY1 = nEndRow;
3078 : : }
3079 : 5170 : }
3080 : :
3081 : :
3082 : : // Auto-Outline
3083 : :
3084 : : template< typename T >
3085 : 10 : short DiffSign( T a, T b )
3086 : : {
3087 : : return (a<b) ? -1 :
3088 [ # # ][ # # ]: 10 : (a>b) ? 1 : 0;
[ - + ][ # # ]
3089 : : }
3090 : :
3091 : :
3092 : 2 : void ScTable::DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
3093 : : {
3094 : 2 : bool bSizeChanged = false;
3095 : :
3096 : : SCCOL nCol;
3097 : : SCROW nRow;
3098 : : SCROW i;
3099 : : bool bFound;
3100 : : ScOutlineArray* pArray;
3101 : : ScBaseCell* pCell;
3102 : 2 : ScRange aRef;
3103 : :
3104 [ + - ]: 2 : StartOutlineTable();
3105 : :
3106 : : // Zeilen
3107 : :
3108 : 2 : SCROW nCount = nEndRow-nStartRow+1;
3109 [ + - ]: 2 : bool* pUsed = new bool[nCount];
3110 [ + + ]: 12 : for (i=0; i<nCount; i++)
3111 : 10 : pUsed[i] = false;
3112 [ + + ]: 10 : for (nCol=nStartCol; nCol<=nEndCol; nCol++)
3113 [ + - ][ + + ]: 8 : if (!aCol[nCol].IsEmptyData())
3114 [ + - ]: 5 : aCol[nCol].FindUsed( nStartRow, nEndRow, pUsed );
3115 : :
3116 : 2 : pArray = pOutlineTable->GetRowArray();
3117 [ + + ]: 12 : for (nRow=nStartRow; nRow<=nEndRow; nRow++)
3118 [ + - ]: 10 : if (pUsed[nRow-nStartRow])
3119 : : {
3120 : 10 : bFound = false;
3121 [ + + ][ + + ]: 35 : for (nCol=nStartCol; nCol<=nEndCol && !bFound; nCol++)
[ + + ]
3122 [ + - ][ + + ]: 25 : if (!aCol[nCol].IsEmptyData())
3123 : : {
3124 [ + - ]: 18 : pCell = aCol[nCol].GetCell( nRow );
3125 [ + + ]: 18 : if (pCell)
3126 [ + + ]: 15 : if ( pCell->GetCellType() == CELLTYPE_FORMULA )
3127 [ + - ][ + - ]: 5 : if (((ScFormulaCell*)pCell)->HasRefListExpressibleAsOneReference( aRef ))
[ + - ]
3128 [ + - ][ + - : 20 : if ( aRef.aStart.Col() == nCol && aRef.aEnd.Col() == nCol &&
+ - + - +
- ][ + - ]
3129 : 10 : aRef.aStart.Tab() == nTab && aRef.aEnd.Tab() == nTab &&
3130 : 5 : DiffSign( aRef.aStart.Row(), nRow ) ==
3131 : 5 : DiffSign( aRef.aEnd.Row(), nRow ) )
3132 : : {
3133 [ + - ][ + - ]: 5 : if (pArray->Insert( aRef.aStart.Row(), aRef.aEnd.Row(), bSizeChanged ))
3134 : : {
3135 : 5 : bFound = true;
3136 : : }
3137 : : }
3138 : : }
3139 : : }
3140 : :
3141 [ + - ]: 2 : delete[] pUsed;
3142 : :
3143 : : // Spalten
3144 : :
3145 : 2 : pArray = pOutlineTable->GetColArray();
3146 [ + + ]: 10 : for (nCol=nStartCol; nCol<=nEndCol; nCol++)
3147 : : {
3148 [ + - ][ + + ]: 8 : if (!aCol[nCol].IsEmptyData())
3149 : : {
3150 : 5 : bFound = false;
3151 [ + - ]: 5 : ScColumnIterator aIter( &aCol[nCol], nStartRow, nEndRow );
3152 [ + - ][ + + ]: 20 : while ( aIter.Next( nRow, pCell ) && !bFound )
[ + - ][ + + ]
3153 : : {
3154 [ + + ]: 15 : if ( pCell->GetCellType() == CELLTYPE_FORMULA )
3155 [ + - ][ + - ]: 5 : if (((ScFormulaCell*)pCell)->HasRefListExpressibleAsOneReference( aRef ))
[ + - ]
3156 [ - + ][ # # : 5 : if ( aRef.aStart.Row() == nRow && aRef.aEnd.Row() == nRow &&
# # # # #
# ][ - + ]
3157 : 0 : aRef.aStart.Tab() == nTab && aRef.aEnd.Tab() == nTab &&
3158 : 0 : DiffSign( aRef.aStart.Col(), nCol ) ==
3159 : 0 : DiffSign( aRef.aEnd.Col(), nCol ) )
3160 : : {
3161 [ # # ][ # # ]: 0 : if (pArray->Insert( aRef.aStart.Col(), aRef.aEnd.Col(), bSizeChanged ))
3162 : : {
3163 : 0 : bFound = true;
3164 : : }
3165 : : }
3166 [ + - ]: 5 : }
3167 : : }
3168 : : }
3169 : 2 : }
3170 : :
3171 : : // CopyData - fuer Query in anderen Bereich
3172 : :
3173 : 0 : void ScTable::CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
3174 : : SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab )
3175 : : {
3176 : : //! wenn fuer mehrere Zeilen benutzt, nach Spalten optimieren!
3177 : :
3178 : 0 : ScAddress aSrc( nStartCol, nStartRow, nTab );
3179 : 0 : ScAddress aDest( nDestCol, nDestRow, nDestTab );
3180 : 0 : ScRange aRange( aSrc, aDest );
3181 : 0 : bool bThisTab = ( nDestTab == nTab );
3182 : 0 : SCROW nDestY = nDestRow;
3183 [ # # ]: 0 : for (SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
3184 : : {
3185 : 0 : aSrc.SetRow( nRow );
3186 : 0 : aDest.SetRow( nDestY );
3187 : 0 : SCCOL nDestX = nDestCol;
3188 [ # # ]: 0 : for (SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
3189 : : {
3190 : 0 : aSrc.SetCol( nCol );
3191 : 0 : aDest.SetCol( nDestX );
3192 [ # # ]: 0 : ScBaseCell* pCell = GetCell( nCol, nRow );
3193 [ # # ]: 0 : if (pCell)
3194 : : {
3195 [ # # ]: 0 : pCell = pCell->Clone( *pDocument );
3196 [ # # ]: 0 : if (pCell->GetCellType() == CELLTYPE_FORMULA)
3197 : : {
3198 : : ((ScFormulaCell*)pCell)->UpdateReference( URM_COPY, aRange,
3199 : : ((SCsCOL) nDestCol) - ((SCsCOL) nStartCol),
3200 : : ((SCsROW) nDestRow) - ((SCsROW) nStartRow),
3201 [ # # ][ # # ]: 0 : ((SCsTAB) nDestTab) - ((SCsTAB) nTab) );
3202 [ # # ]: 0 : ((ScFormulaCell*)pCell)->aPos = aDest;
3203 : : }
3204 : : }
3205 [ # # ]: 0 : if (bThisTab)
3206 : : {
3207 [ # # ]: 0 : PutCell( nDestX, nDestY, pCell );
3208 [ # # ][ # # ]: 0 : SetPattern( nDestX, nDestY, *GetPattern( nCol, nRow ), true );
3209 : : }
3210 : : else
3211 : : {
3212 [ # # ]: 0 : pDocument->PutCell( aDest, pCell );
3213 [ # # ][ # # ]: 0 : pDocument->SetPattern( aDest, *GetPattern( nCol, nRow ), true );
3214 : : }
3215 : :
3216 : 0 : ++nDestX;
3217 : : }
3218 : 0 : ++nDestY;
3219 : : }
3220 : 0 : }
3221 : :
3222 : :
3223 : 0 : bool ScTable::RefVisible(ScFormulaCell* pCell)
3224 : : {
3225 : 0 : ScRange aRef;
3226 : :
3227 [ # # ][ # # ]: 0 : if (pCell->HasOneReference(aRef))
3228 : : {
3229 [ # # ][ # # ]: 0 : if (aRef.aStart.Col()==aRef.aEnd.Col() && aRef.aStart.Tab()==aRef.aEnd.Tab())
[ # # ]
3230 : : {
3231 : : SCROW nEndRow;
3232 [ # # ][ # # ]: 0 : if (!RowFiltered(aRef.aStart.Row(), NULL, &nEndRow))
3233 : : // row not filtered.
3234 : 0 : nEndRow = ::std::numeric_limits<SCROW>::max();
3235 : :
3236 [ # # ][ # # ]: 0 : if (!ValidRow(nEndRow) || nEndRow < aRef.aEnd.Row())
[ # # ]
3237 : 0 : return true; // at least partly visible
3238 : 0 : return false; // completely invisible
3239 : : }
3240 : : }
3241 : :
3242 : 0 : return true; // irgendwie anders
3243 : : }
3244 : :
3245 : :
3246 : 24 : void ScTable::GetUpperCellString(SCCOL nCol, SCROW nRow, rtl::OUString& rStr)
3247 : : {
3248 : 24 : GetInputString(nCol, nRow, rStr);
3249 [ + - ]: 24 : rStr = ScGlobal::pCharClass->uppercase(rStr.trim());
3250 : 24 : }
3251 : :
3252 : :
3253 : : // Berechnen der Groesse der Tabelle und setzen der Groesse an der DrawPage
3254 : :
3255 : 68026 : void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos)
3256 : : {
3257 : 68026 : ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
3258 [ + + ]: 68026 : if( pDrawLayer )
3259 : : {
3260 : 65346 : double fValX = GetColOffset( MAXCOL + 1 ) * HMM_PER_TWIPS;
3261 : 65346 : double fValY = GetRowOffset( MAXROW + 1 ) * HMM_PER_TWIPS;
3262 : 65346 : const long nMax = ::std::numeric_limits<long>::max();
3263 : : // #i113884# Avoid int32 overflow with possible negative results than can cause bad effects.
3264 : : // If the draw page size is smaller than all rows, only the bottom of the sheet is affected.
3265 [ - + ]: 65346 : long x = ( fValX > (double)nMax ) ? nMax : (long) fValX;
3266 [ - + ]: 65346 : long y = ( fValY > (double)nMax ) ? nMax : (long) fValY;
3267 : :
3268 [ + + ]: 65346 : if ( IsLayoutRTL() ) // IsNegativePage
3269 : 4 : x = -x;
3270 : :
3271 [ + - ]: 65346 : pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( x, y ), bUpdateNoteCaptionPos );
3272 : : }
3273 : :
3274 : : // #i102616# actions that modify the draw page size count as sheet modification
3275 : : // (exception: InitDrawLayer)
3276 [ + + ][ + + ]: 68026 : if (bResetStreamValid && IsStreamValid())
[ + + ]
3277 : 3 : SetStreamValid(false);
3278 : 68026 : }
3279 : :
3280 : 3 : void ScTable::SetRangeName(ScRangeName* pNew)
3281 : : {
3282 [ - + ]: 3 : delete mpRangeName;
3283 : 3 : mpRangeName = pNew;
3284 : :
3285 : : //fdo#39792: mark stream as invalid, otherwise new ScRangeName will not be written to file
3286 [ - + ]: 3 : if (IsStreamValid())
3287 : 0 : SetStreamValid(false);
3288 : 3 : }
3289 : :
3290 : 1149 : ScRangeName* ScTable::GetRangeName() const
3291 : : {
3292 [ + + ]: 1149 : if (!mpRangeName)
3293 [ + - ]: 349 : mpRangeName = new ScRangeName;
3294 : 1149 : return mpRangeName;
3295 : : }
3296 : :
3297 : :
3298 : 65784 : sal_uLong ScTable::GetRowOffset( SCROW nRow ) const
3299 : : {
3300 : 65784 : sal_uLong n = 0;
3301 [ + - ][ + - ]: 65784 : if ( mpHiddenRows && mpRowHeights )
[ + - ]
3302 : : {
3303 [ + + ]: 65784 : if (nRow == 0)
3304 : 121 : return 0;
3305 [ + + ]: 65663 : else if (nRow == 1)
3306 : 49 : return GetRowHeight(0);
3307 : :
3308 : 65614 : n = GetTotalRowHeight(0, nRow-1);
3309 : : #if OSL_DEBUG_LEVEL > 0
3310 : : if (n == ::std::numeric_limits<unsigned long>::max())
3311 : : OSL_FAIL("ScTable::GetRowOffset: row heights overflow");
3312 : : #endif
3313 : : }
3314 : : else
3315 : : {
3316 : : OSL_FAIL("GetRowOffset: Daten fehlen");
3317 : : }
3318 : 65784 : return n;
3319 : : }
3320 : :
3321 : 196 : SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const
3322 : : {
3323 : 196 : sal_uInt32 nSum = 0;
3324 : :
3325 : : ScFlatBoolRowSegments::RangeData aData;
3326 [ + + ]: 14680890 : for (SCROW nRow = 0; nRow <= MAXROW; ++nRow)
3327 : : {
3328 [ + - ][ - + ]: 14680876 : if (!mpHiddenRows->getRangeData(nRow, aData))
3329 : 0 : break;
3330 : :
3331 [ - + ]: 14680876 : if (aData.mbValue)
3332 : : {
3333 : 0 : nRow = aData.mnRow2;
3334 : 0 : continue;
3335 : : }
3336 : :
3337 [ + - ]: 14680876 : sal_uInt32 nNew = mpRowHeights->getValue(nRow);
3338 : 14680876 : nSum += nNew;
3339 [ + + ]: 14680876 : if (nSum > nHeight)
3340 : : {
3341 [ + - ]: 182 : return nRow < MAXROW ? nRow + 1 : MAXROW;
3342 : : }
3343 : : }
3344 : 196 : return -1;
3345 : : }
3346 : :
3347 : :
3348 : 65784 : sal_uLong ScTable::GetColOffset( SCCOL nCol ) const
3349 : : {
3350 : 65784 : sal_uLong n = 0;
3351 [ + - ]: 65784 : if ( pColWidth )
3352 : : {
3353 : : SCCOL i;
3354 [ + + ]: 66981400 : for( i = 0; i < nCol; i++ )
3355 [ + + ]: 66915616 : if (!ColHidden(i))
3356 : 66915607 : n += pColWidth[i];
3357 : : }
3358 : : else
3359 : : {
3360 : : OSL_FAIL("GetColumnOffset: Daten fehlen");
3361 : : }
3362 : 65784 : return n;
3363 : : }
3364 : :
3365 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|