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