LibreOffice Module sc (master)  1
refupdat.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <refupdat.hxx>
21 #include <document.hxx>
22 #include <bigrange.hxx>
23 #include <refdata.hxx>
24 
25 #include <osl/diagnose.h>
26 
27 template< typename R, typename S, typename U >
28 static bool lcl_MoveStart( R& rRef, U nStart, S nDelta, U nMask )
29 {
30  bool bCut = false;
31  if ( rRef >= nStart )
32  rRef = sal::static_int_cast<R>( rRef + nDelta );
33  else if ( nDelta < 0 && rRef >= nStart + nDelta )
34  rRef = nStart + nDelta; //TODO: limit ???
35  if ( rRef < 0 )
36  {
37  rRef = 0;
38  bCut = true;
39  }
40  else if ( rRef > nMask )
41  {
42  rRef = nMask;
43  bCut = true;
44  }
45  return bCut;
46 }
47 
48 template< typename R, typename S, typename U >
49 static bool lcl_MoveEnd( R& rRef, U nStart, S nDelta, U nMask )
50 {
51  bool bCut = false;
52  if ( rRef >= nStart )
53  rRef = sal::static_int_cast<R>( rRef + nDelta );
54  else if ( nDelta < 0 && rRef >= nStart + nDelta )
55  rRef = nStart + nDelta - 1; //TODO: limit ???
56  if ( rRef < 0 )
57  {
58  rRef = 0;
59  bCut = true;
60  }
61  else if ( rRef > nMask )
62  {
63  rRef = nMask;
64  bCut = true;
65  }
66  return bCut;
67 }
68 
69 template< typename R, typename S, typename U >
70 static bool lcl_MoveReorder( R& rRef, U nStart, U nEnd, S nDelta )
71 {
72  if ( rRef >= nStart && rRef <= nEnd )
73  {
74  rRef = sal::static_int_cast<R>( rRef + nDelta );
75  return true;
76  }
77 
78  if ( nDelta > 0 ) // move backward
79  {
80  if ( rRef >= nStart && rRef <= nEnd + nDelta )
81  {
82  if ( rRef <= nEnd )
83  rRef = sal::static_int_cast<R>( rRef + nDelta ); // in the moved range
84  else
85  rRef -= nEnd - nStart + 1; // move up
86  return true;
87  }
88  }
89  else // move forward
90  {
91  if ( rRef >= nStart + nDelta && rRef <= nEnd )
92  {
93  if ( rRef >= nStart )
94  rRef = sal::static_int_cast<R>( rRef + nDelta ); // in the moved range
95  else
96  rRef += nEnd - nStart + 1; // move up
97  return true;
98  }
99  }
100 
101  return false;
102 }
103 
104 template< typename R, typename S, typename U >
105 static bool lcl_MoveItCut( R& rRef, S nDelta, U nMask )
106 {
107  bool bCut = false;
108  rRef = sal::static_int_cast<R>( rRef + nDelta );
109  if ( rRef < 0 )
110  {
111  rRef = 0;
112  bCut = true;
113  }
114  else if ( rRef > nMask )
115  {
116  rRef = nMask;
117  bCut = true;
118  }
119  return bCut;
120 }
121 
122 template< typename R, typename U >
123 static void lcl_MoveItWrap( R& rRef, U nMask )
124 {
125  rRef = sal::static_int_cast<R>( rRef );
126  if ( rRef < 0 )
127  rRef += nMask+1;
128  else if ( rRef > nMask )
129  rRef -= nMask+1;
130 }
131 
132 template< typename R, typename S, typename U >
133 static bool IsExpand( R n1, R n2, U nStart, S nD )
134 { // before normal Move...
135  return
136  nD > 0 // Insert
137  && n1 < n2 // at least two Cols/Rows/Tabs in Ref
138  && (
139  (nStart <= n1 && n1 < nStart + nD) // n1 within the Insert
140  || (n2 + 1 == nStart) // n2 directly before Insert
141  ); // n1 < nStart <= n2 is expanded anyway!
142 }
143 
144 template< typename R, typename S, typename U >
145 static void Expand( R& n1, R& n2, U nStart, S nD )
146 { // after normal Move..., only if IsExpand was true before!
147  // first the End
148  if ( n2 + 1 == nStart )
149  { // at End
150  n2 = sal::static_int_cast<R>( n2 + nD );
151  return;
152  }
153  // at the beginning
154  n1 = sal::static_int_cast<R>( n1 - nD );
155 }
156 
157 static bool lcl_IsWrapBig( sal_Int32 nRef, sal_Int32 nDelta )
158 {
159  if ( nRef > 0 && nDelta > 0 )
160  return nRef + nDelta <= 0;
161  else if ( nRef < 0 && nDelta < 0 )
162  return nRef + nDelta >= 0;
163  return false;
164 }
165 
166 static bool lcl_MoveBig( sal_Int32& rRef, sal_Int32 nStart, sal_Int32 nDelta )
167 {
168  bool bCut = false;
169  if ( rRef >= nStart )
170  {
171  if ( nDelta > 0 )
172  bCut = lcl_IsWrapBig( rRef, nDelta );
173  if ( bCut )
174  rRef = nInt32Max;
175  else
176  rRef += nDelta;
177  }
178  return bCut;
179 }
180 
181 static bool lcl_MoveItCutBig( sal_Int32& rRef, sal_Int32 nDelta )
182 {
183  bool bCut = lcl_IsWrapBig( rRef, nDelta );
184  rRef += nDelta;
185  return bCut;
186 }
187 
189  SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
190  SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
191  SCCOL nDx, SCROW nDy, SCTAB nDz,
192  SCCOL& theCol1, SCROW& theRow1, SCTAB& theTab1,
193  SCCOL& theCol2, SCROW& theRow2, SCTAB& theTab2 )
194 {
195  ScRefUpdateRes eRet = UR_NOTHING;
196 
197  SCCOL oldCol1 = theCol1;
198  SCROW oldRow1 = theRow1;
199  SCTAB oldTab1 = theTab1;
200  SCCOL oldCol2 = theCol2;
201  SCROW oldRow2 = theRow2;
202  SCTAB oldTab2 = theTab2;
203 
204  bool bCut1, bCut2;
205 
206  if (eUpdateRefMode == URM_INSDEL)
207  {
208  bool bExpand = pDoc->IsExpandRefs();
209  if ( nDx && (theRow1 >= nRow1) && (theRow2 <= nRow2) &&
210  (theTab1 >= nTab1) && (theTab2 <= nTab2))
211  {
212  bool bExp = (bExpand && IsExpand( theCol1, theCol2, nCol1, nDx ));
213  bCut1 = lcl_MoveStart( theCol1, nCol1, nDx, pDoc->MaxCol() );
214  bCut2 = lcl_MoveEnd( theCol2, nCol1, nDx, pDoc->MaxCol() );
215  if ( theCol2 < theCol1 )
216  {
217  eRet = UR_INVALID;
218  theCol2 = theCol1;
219  }
220  else if ( bCut1 || bCut2 )
221  eRet = UR_UPDATED;
222  if ( bExp )
223  {
224  Expand( theCol1, theCol2, nCol1, nDx );
225  eRet = UR_UPDATED;
226  }
227  if (eRet != UR_NOTHING && oldCol1 == 0 && oldCol2 == pDoc->MaxCol())
228  {
229  eRet = UR_STICKY;
230  theCol1 = oldCol1;
231  theCol2 = oldCol2;
232  }
233  else if (oldCol2 == pDoc->MaxCol() && oldCol1 < pDoc->MaxCol())
234  {
235  // End was sticky, but start may have been moved. Only on range.
236  theCol2 = oldCol2;
237  if (eRet == UR_NOTHING)
238  eRet = UR_STICKY;
239  }
240  // Else, if (bCut2 && theCol2 == pDoc->MaxCol()) then end becomes sticky,
241  // but currently there's nothing to do.
242  }
243  if ( nDy && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
244  (theTab1 >= nTab1) && (theTab2 <= nTab2))
245  {
246  bool bExp = (bExpand && IsExpand( theRow1, theRow2, nRow1, nDy ));
247  bCut1 = lcl_MoveStart( theRow1, nRow1, nDy, pDoc->MaxRow() );
248  bCut2 = lcl_MoveEnd( theRow2, nRow1, nDy, pDoc->MaxRow() );
249  if ( theRow2 < theRow1 )
250  {
251  eRet = UR_INVALID;
252  theRow2 = theRow1;
253  }
254  else if ( bCut1 || bCut2 )
255  eRet = UR_UPDATED;
256  if ( bExp )
257  {
258  Expand( theRow1, theRow2, nRow1, nDy );
259  eRet = UR_UPDATED;
260  }
261  if (eRet != UR_NOTHING && oldRow1 == 0 && oldRow2 == pDoc->MaxRow())
262  {
263  eRet = UR_STICKY;
264  theRow1 = oldRow1;
265  theRow2 = oldRow2;
266  }
267  else if (oldRow2 == pDoc->MaxRow() && oldRow1 < pDoc->MaxRow())
268  {
269  // End was sticky, but start may have been moved. Only on range.
270  theRow2 = oldRow2;
271  if (eRet == UR_NOTHING)
272  eRet = UR_STICKY;
273  }
274  // Else, if (bCut2 && theRow2 == pDoc->MaxRow()) then end becomes sticky,
275  // but currently there's nothing to do.
276  }
277  if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
278  (theRow1 >= nRow1) && (theRow2 <= nRow2) )
279  {
280  SCTAB nMaxTab = pDoc->GetTableCount() - 1;
281  nMaxTab = sal::static_int_cast<SCTAB>(nMaxTab + nDz); // adjust to new count
282  bool bExp = (bExpand && IsExpand( theTab1, theTab2, nTab1, nDz ));
283  bCut1 = lcl_MoveStart( theTab1, nTab1, nDz, nMaxTab );
284  bCut2 = lcl_MoveEnd( theTab2, nTab1, nDz, nMaxTab );
285  if ( theTab2 < theTab1 )
286  {
287  eRet = UR_INVALID;
288  theTab2 = theTab1;
289  }
290  else if ( bCut1 || bCut2 )
291  eRet = UR_UPDATED;
292  if ( bExp )
293  {
294  Expand( theTab1, theTab2, nTab1, nDz );
295  eRet = UR_UPDATED;
296  }
297  }
298  }
299  else if (eUpdateRefMode == URM_MOVE)
300  {
301  if ((theCol1 >= nCol1-nDx) && (theRow1 >= nRow1-nDy) && (theTab1 >= nTab1-nDz) &&
302  (theCol2 <= nCol2-nDx) && (theRow2 <= nRow2-nDy) && (theTab2 <= nTab2-nDz))
303  {
304  if ( nDx )
305  {
306  bCut1 = lcl_MoveItCut( theCol1, nDx, pDoc->MaxCol() );
307  bCut2 = lcl_MoveItCut( theCol2, nDx, pDoc->MaxCol() );
308  if ( bCut1 || bCut2 )
309  eRet = UR_UPDATED;
310  if (eRet != UR_NOTHING && oldCol1 == 0 && oldCol2 == pDoc->MaxCol())
311  {
312  eRet = UR_STICKY;
313  theCol1 = oldCol1;
314  theCol2 = oldCol2;
315  }
316  }
317  if ( nDy )
318  {
319  bCut1 = lcl_MoveItCut( theRow1, nDy, pDoc->MaxRow() );
320  bCut2 = lcl_MoveItCut( theRow2, nDy, pDoc->MaxRow() );
321  if ( bCut1 || bCut2 )
322  eRet = UR_UPDATED;
323  if (eRet != UR_NOTHING && oldRow1 == 0 && oldRow2 == pDoc->MaxRow())
324  {
325  eRet = UR_STICKY;
326  theRow1 = oldRow1;
327  theRow2 = oldRow2;
328  }
329  }
330  if ( nDz )
331  {
332  SCTAB nMaxTab = pDoc->GetTableCount() - 1;
333  bCut1 = lcl_MoveItCut( theTab1, nDz, nMaxTab );
334  bCut2 = lcl_MoveItCut( theTab2, nDz, nMaxTab );
335  if ( bCut1 || bCut2 )
336  eRet = UR_UPDATED;
337  }
338  }
339  }
340  else if (eUpdateRefMode == URM_REORDER)
341  {
342  // so far only for nDz (MoveTab)
343  OSL_ENSURE ( !nDx && !nDy, "URM_REORDER for x and y not yet implemented" );
344 
345  if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
346  (theRow1 >= nRow1) && (theRow2 <= nRow2) )
347  {
348  bCut1 = lcl_MoveReorder( theTab1, nTab1, nTab2, nDz );
349  bCut2 = lcl_MoveReorder( theTab2, nTab1, nTab2, nDz );
350  if ( bCut1 || bCut2 )
351  eRet = UR_UPDATED;
352  }
353  }
354 
355  if ( eRet == UR_NOTHING )
356  {
357  if (oldCol1 != theCol1
358  || oldRow1 != theRow1
359  || oldTab1 != theTab1
360  || oldCol2 != theCol2
361  || oldRow2 != theRow2
362  || oldTab2 != theTab2
363  )
364  eRet = UR_UPDATED;
365  }
366  return eRet;
367 }
368 
369 // simple UpdateReference for ScBigRange (ScChangeAction/ScChangeTrack)
370 // References can also be located outside of the document!
371 // Whole columns/rows (nInt32Min..nInt32Max) stay as such!
373  const ScBigRange& rWhere, sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz,
374  ScBigRange& rWhat )
375 {
376  ScRefUpdateRes eRet = UR_NOTHING;
377  const ScBigRange aOldRange( rWhat );
378 
379  sal_Int32 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2;
380  sal_Int32 theCol1, theRow1, theTab1, theCol2, theRow2, theTab2;
381  rWhere.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
382  rWhat.GetVars( theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 );
383 
384  bool bCut1, bCut2;
385 
386  if (eUpdateRefMode == URM_INSDEL)
387  {
388  if ( nDx && (theRow1 >= nRow1) && (theRow2 <= nRow2) &&
389  (theTab1 >= nTab1) && (theTab2 <= nTab2) &&
390  (theCol1 != nInt32Min || theCol2 != nInt32Max) )
391  {
392  bCut1 = lcl_MoveBig( theCol1, nCol1, nDx );
393  bCut2 = lcl_MoveBig( theCol2, nCol1, nDx );
394  if ( bCut1 || bCut2 )
395  eRet = UR_UPDATED;
396  rWhat.aStart.SetCol( theCol1 );
397  rWhat.aEnd.SetCol( theCol2 );
398  }
399  if ( nDy && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
400  (theTab1 >= nTab1) && (theTab2 <= nTab2) &&
401  (theRow1 != nInt32Min || theRow2 != nInt32Max) )
402  {
403  bCut1 = lcl_MoveBig( theRow1, nRow1, nDy );
404  bCut2 = lcl_MoveBig( theRow2, nRow1, nDy );
405  if ( bCut1 || bCut2 )
406  eRet = UR_UPDATED;
407  rWhat.aStart.SetRow( theRow1 );
408  rWhat.aEnd.SetRow( theRow2 );
409  }
410  if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
411  (theRow1 >= nRow1) && (theRow2 <= nRow2) &&
412  (theTab1 != nInt32Min || theTab2 != nInt32Max) )
413  {
414  bCut1 = lcl_MoveBig( theTab1, nTab1, nDz );
415  bCut2 = lcl_MoveBig( theTab2, nTab1, nDz );
416  if ( bCut1 || bCut2 )
417  eRet = UR_UPDATED;
418  rWhat.aStart.SetTab( theTab1 );
419  rWhat.aEnd.SetTab( theTab2 );
420  }
421  }
422  else if (eUpdateRefMode == URM_MOVE)
423  {
424  if ( rWhere.In( rWhat ) )
425  {
426  if ( nDx && (theCol1 != nInt32Min || theCol2 != nInt32Max) )
427  {
428  bCut1 = lcl_MoveItCutBig( theCol1, nDx );
429  bCut2 = lcl_MoveItCutBig( theCol2, nDx );
430  if ( bCut1 || bCut2 )
431  eRet = UR_UPDATED;
432  rWhat.aStart.SetCol( theCol1 );
433  rWhat.aEnd.SetCol( theCol2 );
434  }
435  if ( nDy && (theRow1 != nInt32Min || theRow2 != nInt32Max) )
436  {
437  bCut1 = lcl_MoveItCutBig( theRow1, nDy );
438  bCut2 = lcl_MoveItCutBig( theRow2, nDy );
439  if ( bCut1 || bCut2 )
440  eRet = UR_UPDATED;
441  rWhat.aStart.SetRow( theRow1 );
442  rWhat.aEnd.SetRow( theRow2 );
443  }
444  if ( nDz && (theTab1 != nInt32Min || theTab2 != nInt32Max) )
445  {
446  bCut1 = lcl_MoveItCutBig( theTab1, nDz );
447  bCut2 = lcl_MoveItCutBig( theTab2, nDz );
448  if ( bCut1 || bCut2 )
449  eRet = UR_UPDATED;
450  rWhat.aStart.SetTab( theTab1 );
451  rWhat.aEnd.SetTab( theTab2 );
452  }
453  }
454  }
455 
456  if ( eRet == UR_NOTHING && rWhat != aOldRange )
457  eRet = UR_UPDATED;
458 
459  return eRet;
460 }
461 
462 void ScRefUpdate::MoveRelWrap( const ScDocument& rDoc, const ScAddress& rPos,
463  SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData& rRef )
464 {
465  ScRange aAbsRange = rRef.toAbs(rDoc, rPos);
466  if( rRef.Ref1.IsColRel() )
467  {
468  SCCOL nCol = aAbsRange.aStart.Col();
469  lcl_MoveItWrap(nCol, nMaxCol);
470  aAbsRange.aStart.SetCol(nCol);
471  }
472  if( rRef.Ref2.IsColRel() )
473  {
474  SCCOL nCol = aAbsRange.aEnd.Col();
475  lcl_MoveItWrap(nCol, nMaxCol);
476  aAbsRange.aEnd.SetCol(nCol);
477  }
478  if( rRef.Ref1.IsRowRel() )
479  {
480  SCROW nRow = aAbsRange.aStart.Row();
481  lcl_MoveItWrap(nRow, nMaxRow);
482  aAbsRange.aStart.SetRow(nRow);
483  }
484  if( rRef.Ref2.IsRowRel() )
485  {
486  SCROW nRow = aAbsRange.aEnd.Row();
487  lcl_MoveItWrap(nRow, nMaxRow);
488  aAbsRange.aEnd.SetRow(nRow);
489  }
490  SCTAB nMaxTab = rDoc.GetTableCount() - 1;
491  if( rRef.Ref1.IsTabRel() )
492  {
493  SCTAB nTab = aAbsRange.aStart.Tab();
494  lcl_MoveItWrap(nTab, nMaxTab);
495  aAbsRange.aStart.SetTab(nTab);
496  }
497  if( rRef.Ref2.IsTabRel() )
498  {
499  SCTAB nTab = aAbsRange.aEnd.Tab();
500  lcl_MoveItWrap(nTab, nMaxTab);
501  aAbsRange.aEnd.SetTab(nTab);
502  }
503 
504  aAbsRange.PutInOrder();
505  rRef.SetRange(rDoc.GetSheetLimits(), aAbsRange, rPos);
506 }
507 
508 void ScRefUpdate::DoTranspose( SCCOL& rCol, SCROW& rRow, SCTAB& rTab,
509  const ScDocument& rDoc, const ScRange& rSource, const ScAddress& rDest )
510 {
511  SCTAB nDz = rDest.Tab() - rSource.aStart.Tab();
512  if (nDz)
513  {
514  SCTAB nNewTab = rTab+nDz;
515  SCTAB nCount = rDoc.GetTableCount();
516  while (nNewTab<0) nNewTab = sal::static_int_cast<SCTAB>( nNewTab + nCount );
517  while (nNewTab>=nCount) nNewTab = sal::static_int_cast<SCTAB>( nNewTab - nCount );
518  rTab = nNewTab;
519  }
520  OSL_ENSURE( rCol>=rSource.aStart.Col() && rRow>=rSource.aStart.Row(),
521  "UpdateTranspose: pos. wrong" );
522 
523  SCCOL nRelX = rCol - rSource.aStart.Col();
524  SCROW nRelY = rRow - rSource.aStart.Row();
525 
526  rCol = static_cast<SCCOL>(static_cast<SCCOLROW>(rDest.Col()) +
527  static_cast<SCCOLROW>(nRelY));
528  rRow = static_cast<SCROW>(static_cast<SCCOLROW>(rDest.Row()) +
529  static_cast<SCCOLROW>(nRelX));
530 }
531 
533  const ScDocument& rDoc, const ScRange& rSource, const ScAddress& rDest, ScRange& rRef )
534 {
535  ScRefUpdateRes eRet = UR_NOTHING;
536  if (rRef.aStart.Col() >= rSource.aStart.Col() && rRef.aEnd.Col() <= rSource.aEnd.Col() &&
537  rRef.aStart.Row() >= rSource.aStart.Row() && rRef.aEnd.Row() <= rSource.aEnd.Row() &&
538  rRef.aStart.Tab() >= rSource.aStart.Tab() && rRef.aEnd.Tab() <= rSource.aEnd.Tab())
539  {
540  // Source range contains the reference range.
541  SCCOL nCol1 = rRef.aStart.Col(), nCol2 = rRef.aEnd.Col();
542  SCROW nRow1 = rRef.aStart.Row(), nRow2 = rRef.aEnd.Row();
543  SCTAB nTab1 = rRef.aStart.Tab(), nTab2 = rRef.aEnd.Tab();
544  DoTranspose(nCol1, nRow1, nTab1, rDoc, rSource, rDest);
545  DoTranspose(nCol2, nRow2, nTab2, rDoc, rSource, rDest);
546  rRef.aStart = ScAddress(nCol1, nRow1, nTab1);
547  rRef.aEnd = ScAddress(nCol2, nRow2, nTab2);
548  eRet = UR_UPDATED;
549  }
550  return eRet;
551 }
552 
553 // UpdateGrow - expands references which point exactly to the area
554 // gets by without document
555 
557  const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY, ScRange& rRef )
558 {
559  ScRefUpdateRes eRet = UR_NOTHING;
560 
561  // in y-direction the Ref may also start one row further below,
562  // if an area contains column heads
563 
564  bool bUpdateX = ( nGrowX &&
565  rRef.aStart.Col() == rArea.aStart.Col() && rRef.aEnd.Col() == rArea.aEnd.Col() &&
566  rRef.aStart.Row() >= rArea.aStart.Row() && rRef.aEnd.Row() <= rArea.aEnd.Row() &&
567  rRef.aStart.Tab() >= rArea.aStart.Tab() && rRef.aEnd.Tab() <= rArea.aEnd.Tab() );
568  bool bUpdateY = ( nGrowY &&
569  rRef.aStart.Col() >= rArea.aStart.Col() && rRef.aEnd.Col() <= rArea.aEnd.Col() &&
570  (rRef.aStart.Row() == rArea.aStart.Row() || rRef.aStart.Row() == rArea.aStart.Row()+1) &&
571  rRef.aEnd.Row() == rArea.aEnd.Row() &&
572  rRef.aStart.Tab() >= rArea.aStart.Tab() && rRef.aEnd.Tab() <= rArea.aEnd.Tab() );
573 
574  if ( bUpdateX )
575  {
576  rRef.aEnd.SetCol(sal::static_int_cast<SCCOL>(rRef.aEnd.Col() + nGrowX));
577  eRet = UR_UPDATED;
578  }
579  if ( bUpdateY )
580  {
581  rRef.aEnd.SetRow(sal::static_int_cast<SCROW>(rRef.aEnd.Row() + nGrowY));
582  eRet = UR_UPDATED;
583  }
584 
585  return eRet;
586 }
587 
588 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsTabRel() const
Definition: refdata.hxx:70
static ScRefUpdateRes Update(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz, SCCOL &theCol1, SCROW &theRow1, SCTAB &theTab1, SCCOL &theCol2, SCROW &theRow2, SCTAB &theTab2)
Definition: refupdat.cxx:188
ScAddress aStart
Definition: address.hxx:500
SCROW Row() const
Definition: address.hxx:262
SC_DLLPUBLIC ScRange toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Definition: refdata.cxx:493
Not updated because the reference is sticky, but would had been updated if it wasn't.
Definition: refupdat.hxx:35
Reference was adjusted/updated.
Definition: refupdat.hxx:33
bool IsExpandRefs() const
Definition: document.hxx:2352
static ScRefUpdateRes UpdateGrow(const ScRange &rArea, SCCOL nGrowX, SCROW nGrowY, ScRange &rRef)
Definition: refupdat.cxx:556
ScAddress aEnd
Definition: address.hxx:501
Some part of the reference became invalid.
Definition: refupdat.hxx:34
static bool lcl_MoveItCut(R &rRef, S nDelta, U nMask)
Definition: refupdat.cxx:105
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:870
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:312
int nCount
SCTAB Tab() const
Definition: address.hxx:271
void SetRow(SCROW nRowP)
Definition: address.hxx:275
bool IsColRel() const
Definition: refdata.hxx:66
static bool lcl_MoveItCutBig(sal_Int32 &rRef, sal_Int32 nDelta)
Definition: refupdat.cxx:181
void SetCol(SCCOL nColP)
Definition: address.hxx:279
ScBigAddress aEnd
Definition: bigrange.hxx:112
static bool lcl_MoveStart(R &rRef, U nStart, S nDelta, U nMask)
Definition: refupdat.cxx:28
static bool lcl_MoveReorder(R &rRef, U nStart, U nEnd, S nDelta)
Definition: refupdat.cxx:70
void SetTab(SCTAB nTabP)
Definition: address.hxx:283
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:869
static void Expand(R &n1, R &n2, U nStart, S nD)
Definition: refupdat.cxx:145
static bool lcl_MoveEnd(R &rRef, U nStart, S nDelta, U nMask)
Definition: refupdat.cxx:49
sal_Int16 SCCOL
Definition: types.hxx:22
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:871
ScSingleRefData Ref1
Definition: refdata.hxx:125
static bool IsExpand(R n1, R n2, U nStart, S nD)
Definition: refupdat.cxx:133
ScSingleRefData Ref2
Definition: refdata.hxx:126
bool In(const ScBigAddress &) const
is Address& in range?
Definition: bigrange.hxx:154
bool IsRowRel() const
Definition: refdata.hxx:68
static bool lcl_IsWrapBig(sal_Int32 nRef, sal_Int32 nDelta)
Definition: refupdat.cxx:157
static void lcl_MoveItWrap(R &rRef, U nMask)
Definition: refupdat.cxx:123
Reference not affected, no change at all.
Definition: refupdat.hxx:32
SCCOL Col() const
Definition: address.hxx:267
void SetCol(sal_Int32 nColP)
Definition: bigrange.hxx:53
UpdateRefMode
Definition: global.hxx:312
sal_Int32 SCROW
Definition: types.hxx:18
ScBigAddress aStart
Definition: bigrange.hxx:111
SC_DLLPUBLIC void PutInOrder()
Definition: address.cxx:1582
static ScRefUpdateRes UpdateTranspose(const ScDocument &rDoc, const ScRange &rSource, const ScAddress &rDest, ScRange &rRef)
Definition: refupdat.cxx:532
static void MoveRelWrap(const ScDocument &rDoc, const ScAddress &rPos, SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData &rRef)
Definition: refupdat.cxx:462
static bool lcl_MoveBig(sal_Int32 &rRef, sal_Int32 nStart, sal_Int32 nDelta)
Definition: refupdat.cxx:166
void SetRange(const ScSheetLimits &rLimits, const ScRange &rRange, const ScAddress &rPos)
Set a new range, assuming that the ordering of the range matches the ordering of the reference data f...
Definition: refdata.cxx:498
ScRefUpdateRes
Definition: refupdat.hxx:31
void SetRow(sal_Int32 nRowP)
Definition: bigrange.hxx:54
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
void GetVars(sal_Int32 &nCol1, sal_Int32 &nRow1, sal_Int32 &nTab1, sal_Int32 &nCol2, sal_Int32 &nRow2, sal_Int32 &nTab2) const
Definition: bigrange.hxx:130
const sal_Int32 nInt32Max
Definition: bigrange.hxx:27
void SetTab(sal_Int32 nTabP)
Definition: bigrange.hxx:55
sal_Int16 SCTAB
Definition: types.hxx:23
static void DoTranspose(SCCOL &rCol, SCROW &rRow, SCTAB &rTab, const ScDocument &rDoc, const ScRange &rSource, const ScAddress &rDest)
Definition: refupdat.cxx:508
const sal_uInt8 R
Definition: xlformula.cxx:50
const sal_Int32 nInt32Min
Definition: bigrange.hxx:26