LibreOffice Module sc (master)  1
table1.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 <scitems.hxx>
21 #include <editeng/justifyitem.hxx>
22 #include <o3tl/safeint.hxx>
23 #include <o3tl/unit_conversion.hxx>
24 #include <unotools/textsearch.hxx>
25 #include <unotools/charclass.hxx>
26 #include <osl/diagnose.h>
27 
28 #include <patattr.hxx>
29 #include <table.hxx>
30 #include <document.hxx>
31 #include <drwlayer.hxx>
32 #include <olinetab.hxx>
33 #include <global.hxx>
34 #include <globstr.hrc>
35 #include <scresid.hxx>
36 #include <refupdat.hxx>
37 #include <markdata.hxx>
38 #include <progress.hxx>
39 #include <prnsave.hxx>
40 #include <tabprotection.hxx>
41 #include <sheetevents.hxx>
42 #include <segmenttree.hxx>
43 #include <dbdata.hxx>
44 #include <conditio.hxx>
45 #include <globalnames.hxx>
46 #include <cellvalue.hxx>
47 #include <scmatrix.hxx>
48 #include <refupdatecontext.hxx>
49 #include <rowheightcontext.hxx>
50 #include <compressedarray.hxx>
51 #include <vcl/svapp.hxx>
52 
53 #include <formula/vectortoken.hxx>
54 #include <token.hxx>
55 
56 #include <vector>
57 #include <memory>
58 
59 using ::std::vector;
60 
61 namespace {
62 
63 ScProgress* GetProgressBar(
64  SCSIZE nCount, SCSIZE nTotalCount, ScProgress* pOuterProgress, const ScDocument* pDoc)
65 {
66  if (nTotalCount < 1000)
67  {
68  // if the total number of rows is less than 1000, don't even bother
69  // with the progress bar because drawing progress bar can be very
70  // expensive especially in GTK.
71  return nullptr;
72  }
73 
74  if (pOuterProgress)
75  return pOuterProgress;
76 
77  if (nCount > 1)
78  return new ScProgress(
79  pDoc->GetDocumentShell(), ScResId(STR_PROGRESS_HEIGHTING), nTotalCount, true);
80 
81  return nullptr;
82 }
83 
84 void GetOptimalHeightsInColumn(
85  sc::RowHeightContext& rCxt, ScColContainer& rCol, SCROW nStartRow, SCROW nEndRow,
86  ScProgress* pProgress, sal_uLong nProgressStart )
87 {
88  assert(nStartRow <= nEndRow);
89 
90  // first, one time over the whole range
91  // (with the last column in the hope that they most likely still are
92  // on standard format)
93 
94 
95  rCol.back().GetOptimalHeight(rCxt, nStartRow, nEndRow, 0, 0);
96 
97  // from there search for the standard height that is in use in the lower part
98 
99  RowHeightsArray& rHeights = rCxt.getHeightArray();
100  sal_uInt16 nMinHeight = rHeights.GetValue(nEndRow);
101  SCSIZE nPos = nEndRow - 1;
102  while ( nPos )
103  {
104  auto aRangeData = rHeights.GetRangeData(nPos-1);
105  if (aRangeData.maValue < nMinHeight)
106  break;
107  nPos = std::max<SCSIZE>(0, aRangeData.mnRow1);
108  }
109 
110  const SCROW nMinStart = nPos;
111 
112  sal_uLong nWeightedCount = nProgressStart + rCol.back().GetWeightedCount(nStartRow, nEndRow);
113  const SCCOL maxCol = rCol.size() - 1; // last col done already above
114  for (SCCOL nCol=0; nCol<maxCol; nCol++)
115  {
116  rCol[nCol].GetOptimalHeight(rCxt, nStartRow, nEndRow, nMinHeight, nMinStart);
117 
118  if (pProgress)
119  {
120  nWeightedCount += rCol[nCol].GetWeightedCount(nStartRow, nEndRow);
121  pProgress->SetState( nWeightedCount );
122  }
123  }
124 }
125 
126 struct OptimalHeightsFuncObjBase
127 {
128  virtual ~OptimalHeightsFuncObjBase() {}
129  virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight, bool bApi) = 0;
130 };
131 
132 struct SetRowHeightOnlyFunc : public OptimalHeightsFuncObjBase
133 {
134  ScTable* mpTab;
135  explicit SetRowHeightOnlyFunc(ScTable* pTab) :
136  mpTab(pTab)
137  {}
138 
139  virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight, bool /* bApi */) override
140  {
141  mpTab->SetRowHeightOnly(nStartRow, nEndRow, nHeight);
142  return false;
143  }
144 };
145 
146 struct SetRowHeightRangeFunc : public OptimalHeightsFuncObjBase
147 {
148  ScTable* mpTab;
149  double mnPPTY;
150 
151  SetRowHeightRangeFunc(ScTable* pTab, double nPPTY) :
152  mpTab(pTab),
153  mnPPTY(nPPTY)
154  {}
155 
156  virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight, bool bApi) override
157  {
158  return mpTab->SetRowHeightRange(nStartRow, nEndRow, nHeight, mnPPTY, bApi);
159  }
160 };
161 
162 bool SetOptimalHeightsToRows(
163  sc::RowHeightContext& rCxt,
164  OptimalHeightsFuncObjBase& rFuncObj,
165  ScBitMaskCompressedArray<SCROW, CRFlags>* pRowFlags, SCROW nStartRow, SCROW nEndRow,
166  bool bApi )
167 {
168  bool bChanged = false;
169  SCROW nRngStart = 0;
170  SCROW nRngEnd = 0;
171  sal_uInt16 nLast = 0;
172  sal_uInt16 nExtraHeight = rCxt.getExtraHeight();
173  for (SCSIZE i = nStartRow; i <= o3tl::make_unsigned(nEndRow); i++)
174  {
175  size_t nIndex;
176  SCROW nRegionEndRow;
177  CRFlags nRowFlag = pRowFlags->GetValue( i, nIndex, nRegionEndRow );
178  if ( nRegionEndRow > nEndRow )
179  nRegionEndRow = nEndRow;
180  SCSIZE nMoreRows = nRegionEndRow - i; // additional equal rows after first
181 
182  bool bAutoSize = !(nRowFlag & CRFlags::ManualSize);
183  if (bAutoSize || rCxt.isForceAutoSize())
184  {
185  if (nExtraHeight)
186  {
187  if (bAutoSize)
188  pRowFlags->SetValue( i, nRegionEndRow, nRowFlag | CRFlags::ManualSize);
189  }
190  else if (!bAutoSize)
191  pRowFlags->SetValue( i, nRegionEndRow, nRowFlag & ~CRFlags::ManualSize);
192 
193  for (SCSIZE nInner = i; nInner <= i + nMoreRows; ++nInner)
194  {
195  if (nLast)
196  {
197  SCROW nRangeRowEnd;
198  size_t nTmp;
199  sal_uInt16 nRangeValue = rCxt.getHeightArray().GetValue(nInner, nTmp, nRangeRowEnd);
200  if (nRangeValue + nExtraHeight == nLast)
201  {
202  nRngEnd = std::min<SCSIZE>(i + nMoreRows, nRangeRowEnd);
203  nInner = nRangeRowEnd;
204  }
205  else
206  {
207  bChanged |= rFuncObj(nRngStart, nRngEnd, nLast, bApi);
208  nLast = 0;
209  }
210  }
211  if (!nLast)
212  {
213  nLast = rCxt.getHeightArray().GetValue(nInner) + rCxt.getExtraHeight();
214  nRngStart = nInner;
215  nRngEnd = nInner;
216  }
217  }
218  }
219  else
220  {
221  if (nLast)
222  bChanged |= rFuncObj(nRngStart, nRngEnd, nLast, bApi);
223  nLast = 0;
224  }
225  i += nMoreRows; // already handled - skip
226  }
227  if (nLast)
228  bChanged |= rFuncObj(nRngStart, nRngEnd, nLast, bApi);
229 
230  return bChanged;
231 }
232 
233 }
234 
235 ScTable::ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName,
236  bool bColInfo, bool bRowInfo ) :
237  aCol( rDoc.GetSheetLimits(), INITIALCOLCOUNT ),
238  aName( rNewName ),
239  aCodeName( rNewName ),
240  nLinkRefreshDelay( 0 ),
241  nLinkMode( ScLinkMode::NONE ),
242  aPageStyle( ScResId(STR_STYLENAME_STANDARD) ),
243  nRepeatStartX( SCCOL_REPEAT_NONE ),
244  nRepeatEndX( SCCOL_REPEAT_NONE ),
245  nRepeatStartY( SCROW_REPEAT_NONE ),
246  nRepeatEndY( SCROW_REPEAT_NONE ),
247  mpRowHeights( static_cast<ScFlatUInt16RowSegments*>(nullptr) ),
248  mpHiddenCols(new ScFlatBoolColSegments(rDoc.MaxCol())),
249  mpHiddenRows(new ScFlatBoolRowSegments(rDoc.MaxRow())),
250  mpFilteredCols(new ScFlatBoolColSegments(rDoc.MaxCol())),
251  mpFilteredRows(new ScFlatBoolRowSegments(rDoc.MaxRow())),
252  nTableAreaX( 0 ),
253  nTableAreaY( 0 ),
254  nTableAreaVisibleX( 0 ),
255  nTableAreaVisibleY( 0 ),
256  nTab( nNewTab ),
257  rDocument( rDoc ),
258  pSortCollator( nullptr ),
259  nLockCount( 0 ),
260  aScenarioColor( COL_LIGHTGRAY ),
261  aTabBgColor( COL_AUTO ),
262  nScenarioFlags(ScScenarioFlags::NONE),
263  mpCondFormatList( new ScConditionalFormatList() ),
264  maLOKFreezeCell(-1, -1, nNewTab),
265  bScenario(false),
266  bLayoutRTL(false),
267  bLoadingRTL(false),
268  bPageSizeValid(false),
269  bTableAreaValid(false),
270  bTableAreaVisibleValid(false),
271  bVisible(true),
272  bStreamValid(false),
273  bPendingRowHeights(false),
274  bCalcNotification(false),
275  bGlobalKeepQuery(false),
276  bPrintEntireSheet(true),
277  bActiveScenario(false),
278  mbPageBreaksValid(false),
279  mbForceBreaks(false),
280  aDefaultColAttrArray(static_cast<SCCOL>(-1), nNewTab, rDoc, nullptr)
281 {
282  if (bColInfo)
283  {
286  }
287 
288  if (bRowInfo)
289  {
292  }
293 
294  if ( rDocument.IsDocVisible() )
295  {
296  // when a sheet is added to a visible document,
297  // initialize its RTL flag from the system locale
299  }
300 
301  ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer();
302  if (pDrawLayer)
303  {
304  if ( pDrawLayer->ScAddPage( nTab ) ) // sal_False (not inserted) during Undo
305  {
306  pDrawLayer->ScRenamePage( nTab, aName );
309  pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( nx, ny ), false );
310  }
311  }
312 
313  for (SCCOL k=0; k < aCol.size(); k++)
314  aCol[k].Init( k, nTab, rDocument, true );
315 }
316 
317 ScTable::~ScTable() COVERITY_NOEXCEPT_FALSE
318 {
319  if (!rDocument.IsInDtorClear())
320  {
321  for (SCCOL nCol = 0; nCol < (aCol.size() - 1); ++nCol)
322  {
323  aCol[nCol].FreeNotes();
324  }
325  // In the dtor, don't delete the pages in the wrong order.
326  // (or else nTab does not reflect the page number!)
327  // In ScDocument::Clear is afterwards used from Clear at the Draw Layer to delete everything.
328 
329  ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer();
330  if (pDrawLayer)
331  pDrawLayer->ScRemovePage( nTab );
332  }
333 
334  pRowFlags.reset();
335  pSheetEvents.reset();
336  pOutlineTable.reset();
337  pSearchText.reset();
338  pRepeatColRange.reset();
339  pRepeatRowRange.reset();
340  pScenarioRanges.reset();
341  mpRangeName.reset();
342  pDBDataNoName.reset();
344 }
345 
346 sal_Int64 ScTable::GetHashCode() const
347 {
348  return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
349 }
350 
351 void ScTable::SetName( const OUString& rNewName )
352 {
353  aName = rNewName;
354  aUpperName.clear(); // invalidated if the name is changed
355 
356  // SetStreamValid is handled in ScDocument::RenameTab
357 }
358 
359 const OUString& ScTable::GetUpperName() const
360 {
361  if (aUpperName.isEmpty() && !aName.isEmpty())
363  return aUpperName;
364 }
365 
366 void ScTable::SetVisible( bool bVis )
367 {
368  if (bVisible != bVis)
369  SetStreamValid(false);
370 
371  bVisible = bVis;
372 }
373 
374 void ScTable::SetStreamValid( bool bSet, bool bIgnoreLock )
375 {
376  if (!bStreamValid && !bSet)
377  return; // shortcut
378  if ( bIgnoreLock || !rDocument.IsStreamValidLocked() )
379  bStreamValid = bSet;
380 }
381 
383 {
384  bPendingRowHeights = bSet;
385 }
386 
387 void ScTable::SetLayoutRTL( bool bSet )
388 {
389  bLayoutRTL = bSet;
390 }
391 
392 void ScTable::SetLoadingRTL( bool bSet )
393 {
394  bLoadingRTL = bSet;
395 }
396 
397 void ScTable::SetTabBgColor(const Color& rColor)
398 {
399  if (aTabBgColor != rColor)
400  {
401  // The tab color has changed. Set this table 'modified'.
402  aTabBgColor = rColor;
403  SetStreamValid(false);
404  }
405 }
406 
407 void ScTable::SetScenario( bool bFlag )
408 {
409  bScenario = bFlag;
410 }
411 
413  const OUString& rDoc, const OUString& rFlt, const OUString& rOpt,
414  const OUString& rTab, sal_uLong nRefreshDelay )
415 {
416  nLinkMode = nMode;
417  aLinkDoc = rDoc; // File
418  aLinkFlt = rFlt; // Filter
419  aLinkOpt = rOpt; // Filter options
420  aLinkTab = rTab; // Sheet name in source file
421  nLinkRefreshDelay = nRefreshDelay; // refresh delay in seconds, 0==off
422 
423  SetStreamValid(false);
424 }
425 
427  double nPPTX, double nPPTY,
428  const Fraction& rZoomX, const Fraction& rZoomY,
429  bool bFormula, const ScMarkData* pMarkData,
430  const ScColWidthParam* pParam )
431 {
432  if ( nCol >= aCol.size() )
433  return ( STD_COL_WIDTH - STD_EXTRA_WIDTH );
434 
435  return aCol[nCol].GetOptimalColWidth( pDev, nPPTX, nPPTY, rZoomX, rZoomY,
436  bFormula, STD_COL_WIDTH - STD_EXTRA_WIDTH, pMarkData, pParam );
437 }
438 
440  OutputDevice* pDev,
441  double nPPTX, double nPPTY,
442  const Fraction& rZoomX, const Fraction& rZoomY,
443  bool bWidth, bool bTotalSize, bool bInPrintTwips )
444 {
445  if ( nCol >= aCol.size() )
446  return 0;
447 
448  ScNeededSizeOptions aOptions;
449  aOptions.bSkipMerged = false; // count merged cells
450  aOptions.bTotalSize = bTotalSize;
451 
452  return aCol[nCol].GetNeededSize
453  ( nRow, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bWidth, aOptions, nullptr, bInPrintTwips );
454 }
455 
457  sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi,
458  ScProgress* pOuterProgress, sal_uLong nProgressStart )
459 {
460  assert(nStartRow <= nEndRow);
461 
462  OSL_ENSURE( rCxt.getExtraHeight() == 0 || rCxt.isForceAutoSize(),
463  "automatic OptimalHeight with Extra" );
464 
466  {
467  return false;
468  }
469 
470  SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
471 
472  ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, &rDocument);
473 
474  mpRowHeights->enableTreeSearch(false);
475 
476  GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, pProgress, nProgressStart);
477 
478  SetRowHeightRangeFunc aFunc(this, rCxt.getPPTY());
479  bool bChanged = SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags.get(), nStartRow, nEndRow, bApi);
480 
481  if ( pProgress != pOuterProgress )
482  delete pProgress;
483 
484  mpRowHeights->enableTreeSearch(true);
485 
486  return bChanged;
487 }
488 
490  sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
491  ScProgress* pOuterProgress, sal_uLong nProgressStart )
492 {
493  OSL_ENSURE( rCxt.getExtraHeight() == 0 || rCxt.isForceAutoSize(),
494  "automatic OptimalHeight with Extra" );
495 
497  return;
498 
499  SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
500 
501  ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, &rDocument);
502 
503  GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, pProgress, nProgressStart);
504 
505  SetRowHeightOnlyFunc aFunc(this);
506 
507  SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags.get(), nStartRow, nEndRow, true);
508 
509  if ( pProgress != pOuterProgress )
510  delete pProgress;
511 }
512 
513 bool ScTable::GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const
514 {
515  bool bFound = false;
516  SCCOL nMaxX = 0;
517  SCROW nMaxY = 0;
518  for (SCCOL i=0; i<aCol.size(); i++)
519  {
520  if (!aCol[i].IsEmptyData())
521  {
522  bFound = true;
523  nMaxX = i;
524  SCROW nRow = aCol[i].GetLastDataPos();
525  if (nRow > nMaxY)
526  nMaxY = nRow;
527  }
528  if ( aCol[i].HasCellNotes() )
529  {
530  SCROW maxNoteRow = aCol[i].GetCellNotesMaxRow();
531  if (maxNoteRow >= nMaxY)
532  {
533  bFound = true;
534  nMaxY = maxNoteRow;
535  }
536  if (i>nMaxX)
537  {
538  bFound = true;
539  nMaxX = i;
540  }
541  }
542  }
543 
544  rEndCol = nMaxX;
545  rEndRow = nMaxY;
546  return bFound;
547 }
548 
549 bool ScTable::GetTableArea( SCCOL& rEndCol, SCROW& rEndRow, bool bCalcHiddens) const
550 {
551  bool bRet = true; //TODO: remember?
552  if (bCalcHiddens)
553  {
554  if (!bTableAreaValid)
555  {
556  bRet = GetPrintArea(nTableAreaX, nTableAreaY, true, bCalcHiddens);
557  bTableAreaValid = true;
558  }
559  rEndCol = nTableAreaX;
560  rEndRow = nTableAreaY;
561  }
562  else
563  {
565  {
566  bRet = GetPrintArea(nTableAreaVisibleX, nTableAreaVisibleY, true, bCalcHiddens);
567  bTableAreaVisibleValid = true;
568  }
569  rEndCol = nTableAreaVisibleX;
570  rEndRow = nTableAreaVisibleY;
571  }
572  return bRet;
573 }
574 
576 
577 bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bCalcHiddens ) const
578 {
579  bool bFound = false;
580  SCCOL nMaxX = 0;
581  SCROW nMaxY = 0;
582  SCCOL i;
583 
584  for (i=0; i<aCol.size(); i++) // Test data
585  {
586  if (bCalcHiddens || !rDocument.ColHidden(i, nTab))
587  {
588  if (!aCol[i].IsEmptyData())
589  {
590  bFound = true;
591  if (i>nMaxX)
592  nMaxX = i;
593  SCROW nColY = aCol[i].GetLastDataPos();
594  if (nColY > nMaxY)
595  nMaxY = nColY;
596  }
597  if (bNotes && aCol[i].HasCellNotes() )
598  {
599  SCROW maxNoteRow = aCol[i].GetCellNotesMaxRow();
600  if (maxNoteRow >= nMaxY)
601  {
602  bFound = true;
603  nMaxY = maxNoteRow;
604  }
605  if (i>nMaxX)
606  {
607  bFound = true;
608  nMaxX = i;
609  }
610  }
611  }
612  }
613 
614  SCCOL nMaxDataX = nMaxX;
615 
616  for (i=0; i<aCol.size(); i++) // Test attribute
617  {
618  if (bCalcHiddens || !rDocument.ColHidden(i, nTab))
619  {
620  SCROW nLastRow;
621  if (aCol[i].GetLastVisibleAttr( nLastRow ))
622  {
623  bFound = true;
624  nMaxX = i;
625  if (nLastRow > nMaxY)
626  nMaxY = nLastRow;
627  }
628  }
629  }
630 
631  if (nMaxX == rDocument.MaxCol()) // omit attribute at the right
632  {
633  --nMaxX;
634  while ( nMaxX>0 && aCol[nMaxX].IsVisibleAttrEqual(aCol[nMaxX+1]) )
635  --nMaxX;
636  }
637 
638  if ( nMaxX < nMaxDataX )
639  {
640  nMaxX = nMaxDataX;
641  }
642  else if ( nMaxX > nMaxDataX )
643  {
644  SCCOL nAttrStartX = nMaxDataX + 1;
645  while ( nAttrStartX < (aCol.size()-1) )
646  {
647  SCCOL nAttrEndX = nAttrStartX;
648  while ( nAttrEndX < (aCol.size()-1) && aCol[nAttrStartX].IsVisibleAttrEqual(aCol[nAttrEndX+1]) )
649  ++nAttrEndX;
650  if ( nAttrEndX + 1 - nAttrStartX >= SC_COLUMNS_STOP )
651  {
652  // found equally-formatted columns behind data -> stop before these columns
653  nMaxX = nAttrStartX - 1;
654 
655  // also don't include default-formatted columns before that
656  SCROW nDummyRow;
657  while ( nMaxX > nMaxDataX && !aCol[nMaxX].GetLastVisibleAttr( nDummyRow ) )
658  --nMaxX;
659  break;
660  }
661  nAttrStartX = nAttrEndX + 1;
662  }
663  }
664 
665  rEndCol = nMaxX;
666  rEndRow = nMaxY;
667  return bFound;
668 }
669 
670 bool ScTable::GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
671  SCCOL& rEndCol ) const
672 {
673  bool bFound = false;
674  SCCOL nMaxX = 0;
675  SCCOL i;
676 
677  for (i=0; i<aCol.size(); i++) // Test attribute
678  {
679  if (aCol[i].HasVisibleAttrIn( nStartRow, nEndRow ))
680  {
681  bFound = true;
682  nMaxX = i;
683  }
684  }
685 
686  if (nMaxX == rDocument.MaxCol()) // omit attribute at the right
687  {
688  --nMaxX;
689  while ( nMaxX>0 && aCol[nMaxX].IsVisibleAttrEqual(aCol[nMaxX+1], nStartRow, nEndRow) )
690  --nMaxX;
691  }
692 
693  for (i=0; i<aCol.size(); i++) // test the data
694  {
695  if (!aCol[i].IsEmptyBlock( nStartRow, nEndRow )) //TODO: bNotes ??????
696  {
697  bFound = true;
698  if (i>nMaxX)
699  nMaxX = i;
700  }
701  }
702 
703  rEndCol = nMaxX;
704  return bFound;
705 }
706 
707 bool ScTable::GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
708  SCROW& rEndRow, bool bNotes ) const
709 {
710  nStartCol = std::min<SCCOL>( nStartCol, aCol.size()-1 );
711  nEndCol = std::min<SCCOL>( nEndCol, aCol.size()-1 );
712  bool bFound = false;
713  SCROW nMaxY = 0;
714  SCCOL i;
715 
716  for (i=nStartCol; i<=nEndCol; i++) // Test attribute
717  {
718  SCROW nLastRow;
719  if (aCol[i].GetLastVisibleAttr( nLastRow ))
720  {
721  bFound = true;
722  if (nLastRow > nMaxY)
723  nMaxY = nLastRow;
724  }
725  }
726 
727  for (i=nStartCol; i<=nEndCol; i++) // Test data
728  {
729  if (!aCol[i].IsEmptyData())
730  {
731  bFound = true;
732  SCROW nColY = aCol[i].GetLastDataPos();
733  if (nColY > nMaxY)
734  nMaxY = nColY;
735  }
736  if (bNotes && aCol[i].HasCellNotes() )
737  {
738  SCROW maxNoteRow =aCol[i].GetCellNotesMaxRow();
739  if (maxNoteRow > nMaxY)
740  {
741  bFound = true;
742  nMaxY = maxNoteRow;
743  }
744  }
745  }
746 
747  rEndRow = nMaxY;
748  return bFound;
749 }
750 
751 bool ScTable::GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const
752 {
753  bool bFound = false;
754  SCCOL nMinX = aCol.size()-1;
755  SCROW nMinY = rDocument.MaxRow();
756  SCCOL i;
757 
758  for (i=0; i<aCol.size(); i++) // Test attribute
759  {
760  SCROW nFirstRow;
761  if (aCol[i].GetFirstVisibleAttr( nFirstRow ))
762  {
763  if (!bFound)
764  nMinX = i;
765  bFound = true;
766  if (nFirstRow < nMinY)
767  nMinY = nFirstRow;
768  }
769  }
770 
771  if (nMinX == 0) // omit attribute at the right
772  {
773  if ( aCol.size() > 1 && aCol[0].IsVisibleAttrEqual(aCol[1]) ) // no single ones
774  {
775  ++nMinX;
776  while ( nMinX<(aCol.size()-1) && aCol[nMinX].IsVisibleAttrEqual(aCol[nMinX-1]) )
777  ++nMinX;
778  }
779  }
780 
781  bool bDatFound = false;
782  for (i=0; i<aCol.size(); i++) // Test data
783  {
784  if (!aCol[i].IsEmptyData())
785  {
786  if (!bDatFound && i<nMinX)
787  nMinX = i;
788  bFound = bDatFound = true;
789  SCROW nRow = aCol[i].GetFirstDataPos();
790  if (nRow < nMinY)
791  nMinY = nRow;
792  }
793  if ( aCol[i].HasCellNotes() )
794  {
795  SCROW minNoteRow = aCol[i].GetCellNotesMinRow();
796  if (minNoteRow <= nMinY)
797  {
798  bFound = true;
799  nMinY = minNoteRow;
800  }
801  if (i<nMinX)
802  {
803  bFound = true;
804  nMinX = i;
805  }
806  }
807  }
808  rStartCol = nMinX;
809  rStartRow = nMinY;
810  return bFound;
811 }
812 
813 void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
814  bool bIncludeOld, bool bOnlyDown ) const
815 {
816  // return the smallest area containing at least all contiguous cells having data. This area
817  // is a square containing also empty cells. It may shrink or extend the area given as input
818  // Flags as modifiers:
819  //
820  // bIncludeOld = true ensure that the returned area contains at least the initial area,
821  // independently of the emptiness of rows / columns (i.e. does not allow shrinking)
822  // bOnlyDown = true means extend / shrink the inputted area only down, i.e modify only rEndRow
823 
824  rStartCol = std::min<SCCOL>( rStartCol, aCol.size()-1 );
825  rEndCol = std::min<SCCOL>( rEndCol, aCol.size()-1 );
826 
827  bool bLeft = false;
828  bool bRight = false;
829  bool bTop = false;
830  bool bBottom = false;
831  bool bChanged = false;
832 
833  // We need to cache sc::ColumnBlockConstPosition per each column.
834  std::vector< sc::ColumnBlockConstPosition > blockPos( rEndCol + 1 );
835  for( SCCOL i = 0; i <= rEndCol; ++i )
836  aCol[ i ].InitBlockPosition( blockPos[ i ] );
837 
838  do
839  {
840  bChanged = false;
841 
842  if (!bOnlyDown)
843  {
844  SCROW nStart = rStartRow;
845  SCROW nEnd = rEndRow;
846  if (nStart>0) --nStart;
847  if (nEnd<rDocument.MaxRow()) ++nEnd;
848 
849  if (rEndCol < (aCol.size()-1))
850  if (!aCol[rEndCol+1].IsEmptyBlock(nStart,nEnd))
851  {
852  assert( int( blockPos.size()) == rEndCol + 1 );
853  ++rEndCol;
854  blockPos.resize( blockPos.size() + 1 );
855  aCol[ rEndCol ].InitBlockPosition( blockPos[ rEndCol ] );
856  bChanged = true;
857  bRight = true;
858  }
859 
860  if (rStartCol > 0)
861  if (!aCol[rStartCol-1].IsEmptyBlock(nStart,nEnd))
862  {
863  --rStartCol;
864  bChanged = true;
865  bLeft = true;
866  }
867 
868  if (rStartRow > 0)
869  {
870  SCROW nTest = rStartRow-1;
871  bool needExtend = false;
872  for ( SCCOL i = rStartCol; i<=rEndCol && !needExtend; i++)
873  if (aCol[i].HasDataAt(blockPos[i], nTest))
874  needExtend = true;
875  if (needExtend)
876  {
877  --rStartRow;
878  bChanged = true;
879  bTop = true;
880  }
881  }
882  }
883 
884  if (rEndRow < rDocument.MaxRow())
885  {
886  SCROW nTest = rEndRow+1;
887  bool needExtend = false;
888  for ( SCCOL i = rStartCol; i<=rEndCol && !needExtend; i++)
889  if (aCol[i].HasDataAt(blockPos[ i ], nTest))
890  needExtend = true;
891  if (needExtend)
892  {
893  ++rEndRow;
894  bChanged = true;
895  bBottom = true;
896  }
897  }
898  }
899  while( bChanged );
900 
901  if ( !bIncludeOld && !bOnlyDown )
902  {
903  if ( !bLeft )
904  while ( rStartCol < rEndCol && rStartCol < (aCol.size()-1) && aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) )
905  ++rStartCol;
906 
907  if ( !bRight )
908  while ( rEndCol > 0 && rStartCol < rEndCol && aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) )
909  --rEndCol;
910 
911  if ( !bTop && rStartRow < rDocument.MaxRow() && rStartRow < rEndRow )
912  {
913  bool bShrink = true;
914  do
915  {
916  for ( SCCOL i = rStartCol; i<=rEndCol && bShrink; i++)
917  if (aCol[i].HasDataAt(rStartRow))
918  bShrink = false;
919  if (bShrink)
920  ++rStartRow;
921  } while (bShrink && rStartRow < rDocument.MaxRow() && rStartRow < rEndRow);
922  }
923  }
924 
925  if ( !bIncludeOld )
926  {
927  if ( !bBottom && rEndRow > 0 && rStartRow < rEndRow )
928  {
929  SCROW nLastDataRow = GetLastDataRow( rStartCol, rEndCol, rEndRow);
930  if (nLastDataRow < rEndRow)
931  rEndRow = std::max( rStartRow, nLastDataRow);
932  }
933  }
934 }
935 
937 {
938  SCCOL nCol1 = rRange.aStart.Col(), nCol2 = rRange.aEnd.Col();
939 
940  if ( nCol1 >= aCol.size() )
941  return false;
942 
943  nCol2 = std::min<SCCOL>( nCol2, aCol.size()-1 );
944 
945  SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
946 
947  SCCOL nFirstNonEmptyCol = -1, nLastNonEmptyCol = -1;
948  SCROW nRowStart = nRow2, nRowEnd = nRow1;
949 
950  for ( SCCOL nCol = nCol1; nCol <= nCol2; ++nCol )
951  {
952  SCROW nRowStartThis = nRow1, nRowEndThis = nRow2;
953  bool bTrimmed = aCol[nCol].TrimEmptyBlocks(nRowStartThis, nRowEndThis);
954  if ( bTrimmed )
955  {
956  if ( nFirstNonEmptyCol == -1 )
957  nFirstNonEmptyCol = nCol;
958  nLastNonEmptyCol = nCol;
959 
960  nRowStart = std::min<SCROW>(nRowStart, nRowStartThis);
961  nRowEnd = std::max<SCROW>(nRowEnd, nRowEndThis);
962  }
963  }
964 
965  if ( nFirstNonEmptyCol == -1 )
966  return false;
967 
968  assert(nFirstNonEmptyCol <= nLastNonEmptyCol);
969  assert(nRowStart <= nRowEnd);
970 
971  rRange.aStart.Set(nFirstNonEmptyCol, nRowStart, rRange.aStart.Tab());
972  rRange.aEnd.Set(nLastNonEmptyCol, nRowEnd, rRange.aEnd.Tab());
973 
974  return true;
975 }
976 
977 bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
978  SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly, bool bStickyTopRow, bool bStickyLeftCol,
979  bool bConsiderCellNotes, bool bConsiderCellDrawObjects, bool bConsiderCellFormats ) const
980 {
981  rStartCol = std::min<SCCOL>( rStartCol, aCol.size()-1 );
982  // check for rEndCol is done below.
983 
984  o_bShrunk = false;
985 
986  PutInOrder( rStartCol, rEndCol);
987  PutInOrder( rStartRow, rEndRow);
988  if (rStartCol < 0)
989  {
990  rStartCol = 0;
991  o_bShrunk = true;
992  }
993  if (rStartRow < 0)
994  {
995  rStartRow = 0;
996  o_bShrunk = true;
997  }
998  if (rEndCol >= aCol.size())
999  {
1000  rEndCol = aCol.size()-1;
1001  o_bShrunk = true;
1002  }
1003  if (rEndRow > rDocument.MaxRow())
1004  {
1005  rEndRow = rDocument.MaxRow();
1006  o_bShrunk = true;
1007  }
1008 
1009  while (rStartCol < rEndCol)
1010  {
1011  if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
1012  {
1013  if (bConsiderCellNotes && !aCol[rEndCol].IsNotesEmptyBlock( rStartRow, rEndRow ))
1014  break;
1015 
1016  if (bConsiderCellDrawObjects && !aCol[rEndCol].IsDrawObjectsEmptyBlock( rStartRow, rEndRow ))
1017  break;
1018 
1019  if (bConsiderCellFormats && aCol[rEndCol].HasVisibleAttrIn(rStartRow, rEndRow))
1020  break;
1021 
1022  --rEndCol;
1023  o_bShrunk = true;
1024  }
1025  else
1026  break; // while
1027  }
1028 
1029  if (!bStickyLeftCol)
1030  {
1031  while (rStartCol < rEndCol)
1032  {
1033  if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
1034  {
1035  if (bConsiderCellNotes && !aCol[rStartCol].IsNotesEmptyBlock( rStartRow, rEndRow ))
1036  break;
1037 
1038  if (bConsiderCellDrawObjects && !aCol[rStartCol].IsDrawObjectsEmptyBlock( rStartRow, rEndRow ))
1039  break;
1040 
1041  if (bConsiderCellFormats && aCol[rEndCol].HasVisibleAttrIn(rStartRow, rEndRow))
1042  break;
1043 
1044  ++rStartCol;
1045  o_bShrunk = true;
1046  }
1047  else
1048  break; // while
1049  }
1050  }
1051 
1052  if (!bColumnsOnly)
1053  {
1054  if (!bStickyTopRow)
1055  {
1056  while (rStartRow < rEndRow)
1057  {
1058  bool bFound = false;
1059  for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
1060  {
1061  if (aCol[i].HasDataAt(rStartRow, bConsiderCellNotes, bConsiderCellDrawObjects,
1062  bConsiderCellFormats))
1063  bFound = true;
1064  }
1065  if (!bFound)
1066  {
1067  ++rStartRow;
1068  o_bShrunk = true;
1069  }
1070  else
1071  break; // while
1072  }
1073  }
1074 
1075  while (rStartRow < rEndRow)
1076  {
1077  SCROW nLastDataRow = GetLastDataRow(rStartCol, rEndCol, rEndRow, bConsiderCellNotes,
1078  bConsiderCellDrawObjects, bConsiderCellFormats);
1079  if (0 <= nLastDataRow && nLastDataRow < rEndRow)
1080  {
1081  rEndRow = std::max( rStartRow, nLastDataRow);
1082  o_bShrunk = true;
1083  }
1084  else
1085  break; // while
1086  }
1087  }
1088 
1089  return rStartCol != rEndCol || (bColumnsOnly ?
1090  !aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow) :
1091  (rStartRow != rEndRow ||
1092  aCol[rStartCol].HasDataAt( rStartRow, bConsiderCellNotes, bConsiderCellDrawObjects, bConsiderCellFormats )));
1093 }
1094 
1095 SCROW ScTable::GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow, bool bConsiderCellNotes,
1096  bool bConsiderCellDrawObjects, bool bConsiderCellFormats ) const
1097 {
1098  if ( !IsColValid( nCol1 ) || !ValidCol( nCol2 ) )
1099  return -1;
1100 
1101  nCol2 = std::min<SCCOL>( nCol2, aCol.size() - 1 );
1102 
1103  SCROW nNewLastRow = 0;
1104  for (SCCOL i = nCol1; i <= nCol2; ++i)
1105  {
1106  SCROW nThis = aCol[i].GetLastDataPos(nLastRow, bConsiderCellNotes, bConsiderCellDrawObjects,
1107  bConsiderCellFormats);
1108  if (nNewLastRow < nThis)
1109  nNewLastRow = nThis;
1110  }
1111 
1112  return nNewLastRow;
1113 }
1114 
1116  SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const
1117 {
1118  SCCOL nStartColOrig = nStartCol;
1119  SCCOL nEndColOrig = nEndCol;
1120  nStartCol = std::min<SCCOL>( nStartCol, aCol.size()-1 );
1121  nEndCol = std::min<SCCOL>( nEndCol, aCol.size()-1 );
1122 
1123  // The region is not allocated and does not contain any data.
1124  if ( nStartColOrig != nStartCol )
1125  return ( ((eDir == DIR_BOTTOM) || (eDir == DIR_TOP)) ?
1126  static_cast<SCSIZE>(nEndRow - nStartRow + 1) :
1127  static_cast<SCSIZE>(nEndColOrig - nStartColOrig + 1) );
1128 
1129  SCSIZE nGapRight = static_cast<SCSIZE>(nEndColOrig - nEndCol);
1130  SCSIZE nCount = 0;
1131  SCCOL nCol;
1132  if ((eDir == DIR_BOTTOM) || (eDir == DIR_TOP))
1133  {
1134  nCount = static_cast<SCSIZE>(nEndRow - nStartRow + 1);
1135  for (nCol = nStartCol; nCol <= nEndCol; nCol++)
1136  nCount = std::min(nCount, aCol[nCol].GetEmptyLinesInBlock(nStartRow, nEndRow, eDir));
1137  }
1138  else if (eDir == DIR_RIGHT)
1139  {
1140  nCol = nEndCol;
1141  while ((nCol >= nStartCol) &&
1142  aCol[nCol].IsEmptyBlock(nStartRow, nEndRow))
1143  {
1144  nCount++;
1145  nCol--;
1146  }
1147  nCount += nGapRight;
1148  }
1149  else
1150  {
1151  nCol = nStartCol;
1152  while ((nCol <= nEndCol) && aCol[nCol].IsEmptyBlock(nStartRow, nEndRow))
1153  {
1154  nCount++;
1155  nCol++;
1156  }
1157 
1158  // If the area between nStartCol and nEndCol are empty,
1159  // add the count of unallocated columns on the right.
1160  if ( nCol > nEndCol )
1161  nCount += nGapRight;
1162  }
1163  return nCount;
1164 }
1165 
1166 bool ScTable::IsEmptyLine( SCROW nRow, SCCOL nStartCol, SCCOL nEndCol ) const
1167 {
1168  // The range of columns are unallocated hence empty.
1169  if ( nStartCol >= aCol.size() )
1170  return true;
1171 
1172  nEndCol = std::min<SCCOL>( nEndCol, aCol.size()-1 );
1173 
1174  bool bFound = false;
1175  for (SCCOL i=nStartCol; i<=nEndCol && !bFound; i++)
1176  if (aCol[i].HasDataAt(nRow))
1177  bFound = true;
1178  return !bFound;
1179 }
1180 
1181 void ScTable::LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const
1182 {
1183  rStartCol = std::min<SCCOL>( rStartCol, aCol.size()-1 );
1184  rEndCol = std::min<SCCOL>( rEndCol, aCol.size()-1 );
1185 
1186  while ( rStartCol<rEndCol && aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) )
1187  ++rStartCol;
1188 
1189  while ( rStartCol<rEndCol && aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) )
1190  --rEndCol;
1191 
1192  while ( rStartRow<rEndRow && IsEmptyLine(rStartRow, rStartCol, rEndCol) )
1193  ++rStartRow;
1194 
1195  // Optimised loop for finding the bottom of the area, can be costly in large
1196  // spreadsheets.
1197  SCROW lastDataPos = 0;
1198  for (SCCOL i=rStartCol; i<=rEndCol; i++)
1199  lastDataPos = std::max(lastDataPos, aCol[i].GetLastDataPos());
1200  // reduce EndRow to the last row with data
1201  rEndRow = std::min(rEndRow, lastDataPos);
1202  // but make sure EndRow is >= StartRow
1203  rEndRow = std::max(rStartRow, rEndRow);
1204 }
1205 
1206 SCCOL ScTable::FindNextVisibleCol( SCCOL nCol, bool bRight ) const
1207 {
1208  if(bRight)
1209  {
1210  nCol++;
1211  SCCOL nEnd = 0;
1212  bool bHidden = rDocument.ColHidden(nCol, nTab, nullptr, &nEnd);
1213  if(bHidden)
1214  nCol = nEnd +1;
1215 
1216  return std::min<SCCOL>(rDocument.MaxCol(), nCol);
1217  }
1218  else
1219  {
1220  nCol--;
1221  SCCOL nStart = rDocument.MaxCol();
1222  bool bHidden = rDocument.ColHidden(nCol, nTab, &nStart);
1223  if(bHidden)
1224  nCol = nStart - 1;
1225 
1226  return std::max<SCCOL>(0, nCol);
1227  }
1228 }
1229 
1231 {
1232  const SCCOL nLastCol = aCol.size() - 1;
1233  if(bRight)
1234  {
1235  // If nCol is the last allocated column index, there won't be any content to its right.
1236  // To maintain the original return behaviour, return rDocument.MaxCol().
1237  if(nCol >= nLastCol)
1238  return rDocument.MaxCol();
1239 
1240  do
1241  {
1242  nCol++;
1243  SCCOL nEndCol = 0;
1244  bool bHidden = rDocument.ColHidden( nCol, nTab, nullptr, &nEndCol );
1245  if(bHidden)
1246  {
1247  nCol = nEndCol +1;
1248  // Can end search early as there is no data after nLastCol.
1249  // For nCol == nLastCol, it may still have data so don't want to return rDocument.MaxCol().
1250  if(nCol > nLastCol)
1251  return rDocument.MaxCol();
1252  }
1253 
1254  if(aCol[nCol].HasVisibleDataAt(nRow))
1255  return nCol;
1256  }
1257  while(nCol < nLastCol); // Stop search as soon as the last allocated column is searched.
1258 
1259  return rDocument.MaxCol();
1260  }
1261  else
1262  {
1263  // If nCol is in the unallocated range [nLastCol+1, rDocument.MaxCol()], then move it directly to nLastCol
1264  // as there is no data in the unallocated range. This also makes the search faster and avoids
1265  // the need for more range checks in the loop below.
1266  if ( nCol > nLastCol )
1267  nCol = nLastCol;
1268 
1269  if(nCol == 0)
1270  return 0;
1271 
1272  do
1273  {
1274  nCol--;
1275  SCCOL nStartCol = rDocument.MaxCol();
1276  bool bHidden = rDocument.ColHidden( nCol, nTab, &nStartCol );
1277  if(bHidden)
1278  {
1279  nCol = nStartCol -1;
1280  if(nCol <= 0)
1281  return 0;
1282  }
1283 
1284  if(aCol[nCol].HasVisibleDataAt(nRow))
1285  return nCol;
1286  }
1287  while(nCol > 0);
1288 
1289  return 0;
1290  }
1291 }
1292 
1293 void ScTable::FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const
1294 {
1295  const SCCOL nLastCol = aCol.size() - 1;
1296 
1297  if (eDirection == SC_MOVE_LEFT || eDirection == SC_MOVE_RIGHT)
1298  {
1299  SCCOL nNewCol = rCol;
1300  bool bThere = ( nNewCol <= nLastCol ) && aCol[nNewCol].HasVisibleDataAt(rRow);
1301  bool bRight = (eDirection == SC_MOVE_RIGHT);
1302  if (bThere)
1303  {
1304  if(nNewCol >= rDocument.MaxCol() && eDirection == SC_MOVE_RIGHT)
1305  return;
1306  else if(nNewCol == 0 && eDirection == SC_MOVE_LEFT)
1307  return;
1308 
1309  SCCOL nNextCol = FindNextVisibleCol( nNewCol, bRight );
1310 
1311  if( nNextCol <= nLastCol && aCol[nNextCol].HasVisibleDataAt(rRow) )
1312  {
1313  bool bFound = false;
1314  nNewCol = nNextCol;
1315  do
1316  {
1317  nNextCol = FindNextVisibleCol( nNewCol, bRight );
1318  if( nNextCol <= nLastCol && aCol[nNextCol].HasVisibleDataAt(rRow) )
1319  nNewCol = nNextCol;
1320  else
1321  bFound = true;
1322  }
1323  while(!bFound && nNextCol > 0 && nNextCol < rDocument.MaxCol());
1324  }
1325  else
1326  {
1327  nNewCol = FindNextVisibleColWithContent(nNewCol, bRight, rRow);
1328  }
1329  }
1330  else
1331  {
1332  nNewCol = FindNextVisibleColWithContent(nNewCol, bRight, rRow);
1333  }
1334 
1335  if (nNewCol<0)
1336  nNewCol=0;
1337  if (nNewCol>rDocument.MaxCol())
1338  nNewCol=rDocument.MaxCol();
1339  rCol = nNewCol;
1340  }
1341  else
1342  {
1343  if ( rCol <= nLastCol )
1344  aCol[rCol].FindDataAreaPos(rRow,eDirection == SC_MOVE_DOWN);
1345  else
1346  {
1347  // The cell (rCol, rRow) is equivalent to an empty cell (although not allocated).
1348  // Set rRow to 0 or rDocument.MaxRow() depending on eDirection to maintain the behaviour of
1349  // ScColumn::FindDataAreaPos() when the given column is empty.
1350  rRow = ( eDirection == SC_MOVE_DOWN ) ? rDocument.MaxRow() : 0;
1351  }
1352  }
1353 }
1354 
1355 bool ScTable::ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
1356  bool bMarked, bool bUnprotected ) const
1357 {
1358  if (!ValidCol(nCol) || !ValidRow(nRow))
1359  return false;
1360 
1361  if (rDocument.HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Overlapped))
1362  // Skip an overlapped cell.
1363  return false;
1364 
1365  if (bMarked && !rMark.IsCellMarked(nCol,nRow))
1366  return false;
1367 
1368  /* TODO: for cursor movement *only* this should even take the protection
1369  * options (select locked, select unlocked) into account, see
1370  * ScTabView::SkipCursorHorizontal() and ScTabView::SkipCursorVertical(). */
1371  if (bUnprotected && rDocument.HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Protected))
1372  return false;
1373 
1374  if (bMarked || bUnprotected) //TODO: also in other case ???
1375  {
1376  // Hidden cells must be skipped, as the cursor would end up on the next cell
1377  // even if it is protected or not marked.
1378  //TODO: control per Extra-Parameter, only for Cursor movement ???
1379 
1380  if (RowHidden(nRow))
1381  return false;
1382 
1383  if (ColHidden(nCol))
1384  return false;
1385  }
1386 
1387  return true;
1388 }
1389 
1390 // Skips the current cell if it is Hidden, Overlapped or Protected and Sheet is Protected
1391 bool ScTable::SkipRow( const SCCOL nCol, SCROW& rRow, const SCROW nMovY,
1392  const ScMarkData& rMark, const bool bUp, const SCROW nUsedY,
1393  const bool bMarked, const bool bSheetProtected ) const
1394 {
1395  if ( !ValidRow( rRow ))
1396  return false;
1397 
1398  if (bSheetProtected && rDocument.HasAttrib( nCol, rRow, nTab, nCol, rRow, nTab, HasAttrFlags::Protected))
1399  {
1400  if ( rRow > nUsedY )
1401  rRow = (bUp ? nUsedY : rDocument.MaxRow() + nMovY);
1402  else
1403  rRow += nMovY;
1404 
1405  if (bMarked)
1406  rRow = rMark.GetNextMarked( nCol, rRow, bUp );
1407 
1408  return true;
1409  }
1410  else
1411  {
1412  bool bRowHidden = RowHidden( rRow );
1413  bool bOverlapped = rDocument.HasAttrib( nCol, rRow, nTab, nCol, rRow, nTab, HasAttrFlags::Overlapped );
1414 
1415  if ( bRowHidden || bOverlapped )
1416  {
1417  rRow += nMovY;
1418  if (bMarked)
1419  rRow = rMark.GetNextMarked( nCol, rRow, bUp );
1420 
1421  return true;
1422  }
1423  }
1424 
1425  return false;
1426 }
1427 
1428 void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
1429  bool bMarked, bool bUnprotected, const ScMarkData& rMark, SCCOL nTabStartCol ) const
1430 {
1431  // Ensure bMarked is set only if there is a mark.
1432  assert( !bMarked || rMark.IsMarked() || rMark.IsMultiMarked());
1433 
1434  const bool bSheetProtected = IsProtected();
1435 
1436  if ( bUnprotected && !bSheetProtected ) // Is sheet really protected?
1437  bUnprotected = false;
1438 
1439  SCCOL nCol = rCol + nMovX;
1440  SCROW nRow = rRow + nMovY;
1441 
1442  SCCOL nStartCol, nEndCol;
1443  SCROW nStartRow, nEndRow;
1444  if (bMarked)
1445  {
1447  if (rMark.IsMarked())
1448  rMark.GetMarkArea( aRange);
1449  else if (rMark.IsMultiMarked())
1450  rMark.GetMultiMarkArea( aRange);
1451  else
1452  {
1453  // Covered by assert() above, but for NDEBUG build.
1454  if (ValidColRow(nCol,nRow))
1455  {
1456  rCol = nCol;
1457  rRow = nRow;
1458  }
1459  return;
1460  }
1461  nStartCol = aRange.aStart.Col();
1462  nStartRow = aRange.aStart.Row();
1463  nEndCol = aRange.aEnd.Col();
1464  nEndRow = aRange.aEnd.Row();
1465  }
1466  else if (bUnprotected)
1467  {
1468  nStartCol = 0;
1469  nStartRow = 0;
1470  nEndCol = rCol;
1471  nEndRow = rRow;
1472  rDocument.GetPrintArea( nTab, nEndCol, nEndRow, true );
1473  // Add some cols/rows to the print area (which is "content or
1474  // visually different from empty") to enable travelling through
1475  // protected forms with empty cells and no visual indicator.
1476  // 42 might be good enough and not too much...
1477  nEndCol = std::min<SCCOL>( nEndCol+42, rDocument.MaxCol());
1478  nEndRow = std::min<SCROW>( nEndRow+42, rDocument.MaxRow());
1479  }
1480  else
1481  {
1482  // Invalid values show up for instance for Tab, when nothing is
1483  // selected and not protected (left / right edge), then leave values
1484  // unchanged.
1485  if (ValidColRow(nCol,nRow))
1486  {
1487  rCol = nCol;
1488  rRow = nRow;
1489  }
1490 
1491  // Caller ensures actually moving nMovY to jump to prev/next row's
1492  // start col.
1493  if (nTabStartCol != SC_TABSTART_NONE)
1494  rCol = nTabStartCol;
1495 
1496  return;
1497  }
1498 
1499  if ( nMovY && (bMarked || bUnprotected))
1500  {
1501  do
1502  {
1503  const bool bUp = (nMovY < 0);
1504  const SCCOL nColAdd = (bUp ? -1 : 1);
1505 
1506  if (bMarked)
1507  nRow = rMark.GetNextMarked( nCol, nRow, bUp );
1508 
1509  if (nTabStartCol != SC_TABSTART_NONE)
1510  {
1511  /* NOTE: If current rCol < nTabStartCol when going down, there
1512  * is no way to detect if the previous Tab wrapped around to
1513  * the next row or if it was a Shift+Tab going backwards. The
1514  * result after a wrap is an odd jump to the next row's
1515  * nTabStartCol, which is logical though and always has been
1516  * the case. Similar for rCol > nTabStartCol when going up.
1517  * Related, it would be nice to limit advancing the position
1518  * within bounds even if another wrap would occur, but again we
1519  * can't tell if previously Tab or Shift+Tab was used, so we
1520  * don't know if it would be nTabStartCol to nEndCol (for Tab)
1521  * or nStartCol to nTabStartCol (for Shift+Tab). */
1522 
1523  // Continue moving horizontally.
1524  nMovX = nColAdd;
1525  nCol = nTabStartCol;
1526  break; // do
1527  }
1528 
1529  while ( SkipRow( nCol, nRow, nMovY, rMark, bUp, nEndRow, bMarked, bSheetProtected ))
1530  ;
1531 
1532  sal_uInt16 nWrap = 0;
1533  while ( nRow < nStartRow || nRow > nEndRow )
1534  {
1535  nCol += nColAdd;
1536 
1537  while (nStartCol <= nCol && nCol <= nEndCol && ValidCol(nCol) && ColHidden(nCol))
1538  nCol += nColAdd; // skip hidden cols
1539 
1540  if (nCol < nStartCol)
1541  {
1542  nCol = nEndCol;
1543 
1544  if (++nWrap >= 2)
1545  return;
1546  }
1547  else if (nCol > nEndCol)
1548  {
1549  nCol = nStartCol;
1550 
1551  if (++nWrap >= 2)
1552  return;
1553  }
1554  if (nRow < nStartRow)
1555  nRow = nEndRow;
1556  else if (nRow > nEndRow)
1557  nRow = nStartRow;
1558 
1559  if (bMarked)
1560  nRow = rMark.GetNextMarked( nCol, nRow, bUp );
1561 
1562  while ( SkipRow( nCol, nRow, nMovY, rMark, bUp, nEndRow, bMarked, bSheetProtected ))
1563  ;
1564  }
1565  } while (false);
1566  }
1567 
1568  if ( nMovX && ( bMarked || bUnprotected ) )
1569  {
1570  // wrap initial skip counting:
1571  if (nCol < nStartCol)
1572  {
1573  nCol = nEndCol;
1574  --nRow;
1575  if (nRow < nStartRow)
1576  nRow = nEndRow;
1577  }
1578  if (nCol > nEndCol)
1579  {
1580  nCol = nStartCol;
1581  ++nRow;
1582  if (nRow > nEndRow)
1583  nRow = nStartRow;
1584  }
1585 
1586  if ( !ValidNextPos(nCol, nRow, rMark, bMarked, bUnprotected) )
1587  {
1588  const SCCOL nColCount = nEndCol - nStartCol + 1;
1589  std::unique_ptr<SCROW[]> pNextRows( new SCROW[nColCount]);
1590  const SCCOL nLastCol = aCol.size() - 1;
1591  const bool bUp = (nMovX < 0); // Moving left also means moving up in rows.
1592  const SCROW nRowAdd = (bUp ? -1 : 1);
1593  sal_uInt16 nWrap = 0;
1594 
1595  if (bUp)
1596  {
1597  for (SCCOL i = 0; i < nColCount; ++i)
1598  pNextRows[i] = (i + nStartCol > nCol) ? (nRow + nRowAdd) : nRow;
1599  }
1600  else
1601  {
1602  for (SCCOL i = 0; i < nColCount; ++i)
1603  pNextRows[i] = (i + nStartCol < nCol) ? (nRow + nRowAdd) : nRow;
1604  }
1605  do
1606  {
1607  SCROW nNextRow = pNextRows[nCol - nStartCol] + nRowAdd;
1608  if ( bMarked )
1609  nNextRow = rMark.GetNextMarked( nCol, nNextRow, bUp );
1610  if ( bUnprotected )
1611  nNextRow = ( nCol <= nLastCol ) ? aCol[nCol].GetNextUnprotected( nNextRow, bUp ) :
1612  aDefaultColAttrArray.GetNextUnprotected( nNextRow, bUp );
1613  pNextRows[nCol - nStartCol] = nNextRow;
1614 
1615  if (bUp)
1616  {
1617  SCROW nMaxRow = nStartRow - 1;
1618  for (SCCOL i = 0; i < nColCount; ++i)
1619  {
1620  if (pNextRows[i] >= nMaxRow) // when two equal the right one
1621  {
1622  nMaxRow = pNextRows[i];
1623  nCol = i + nStartCol;
1624  }
1625  }
1626  nRow = nMaxRow;
1627 
1628  if ( nRow < nStartRow )
1629  {
1630  if (++nWrap >= 2)
1631  return;
1632  nCol = nEndCol;
1633  nRow = nEndRow;
1634  for (SCCOL i = 0; i < nColCount; ++i)
1635  pNextRows[i] = nEndRow; // do it all over again
1636  }
1637  }
1638  else
1639  {
1640  SCROW nMinRow = nEndRow + 1;
1641  for (SCCOL i = 0; i < nColCount; ++i)
1642  {
1643  if (pNextRows[i] < nMinRow) // when two equal the left one
1644  {
1645  nMinRow = pNextRows[i];
1646  nCol = i + nStartCol;
1647  }
1648  }
1649  nRow = nMinRow;
1650 
1651  if ( nRow > nEndRow )
1652  {
1653  if (++nWrap >= 2)
1654  return;
1655  nCol = nStartCol;
1656  nRow = nStartRow;
1657  for (SCCOL i = 0; i < nColCount; ++i)
1658  pNextRows[i] = nStartRow; // do it all over again
1659  }
1660  }
1661  }
1662  while ( !ValidNextPos(nCol, nRow, rMark, bMarked, bUnprotected) );
1663  }
1664  }
1665 
1666  if (ValidColRow(nCol,nRow))
1667  {
1668  rCol = nCol;
1669  rRow = nRow;
1670  }
1671 }
1672 
1673 bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const
1674 {
1675  ++rRow; // next row
1676 
1677  while ( rCol < aCol.size() )
1678  {
1679  ScMarkArray aArray( rMark.GetMarkArray( rCol ) );
1680  while ( rRow <= rDocument.MaxRow() )
1681  {
1682  SCROW nStart = aArray.GetNextMarked( rRow, false );
1683  if ( nStart <= rDocument.MaxRow() )
1684  {
1685  SCROW nEnd = aArray.GetMarkEnd( nStart, false );
1686 
1687  const sc::CellStoreType& rCells = aCol[rCol].maCells;
1688  std::pair<sc::CellStoreType::const_iterator,size_t> aPos = rCells.position(nStart);
1689  sc::CellStoreType::const_iterator it = aPos.first;
1690  SCROW nTestRow = nStart;
1691  if (it->type == sc::element_type_empty)
1692  {
1693  // Skip the empty block.
1694  nTestRow += it->size - aPos.second;
1695  ++it;
1696  if (it == rCells.end())
1697  {
1698  // No more block. Move on to the next column.
1699  rRow = rDocument.MaxRow() + 1;
1700  continue;
1701  }
1702  }
1703 
1704  if (nTestRow <= nEnd)
1705  {
1706  // Cell found.
1707  rRow = nTestRow;
1708  return true;
1709  }
1710 
1711  rRow = nEnd + 1; // Search for next selected range
1712  }
1713  else
1714  rRow = rDocument.MaxRow() + 1; // End of column
1715  }
1716  rRow = 0;
1717  ++rCol; // test next column
1718  }
1719 
1720  // Though searched only the allocated columns, it is equivalent to a search till rDocument.MaxCol().
1721  rCol = rDocument.MaxCol() + 1;
1722  return false; // Through all columns
1723 }
1724 
1725 void ScTable::UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1726  SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1727  SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos )
1728 {
1729  if ( !(nTab >= nTab1 && nTab <= nTab2 && nDz == 0) ) // only within the table
1730  return;
1731 
1732  ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer();
1733  if ( eUpdateRefMode != URM_COPY && pDrawLayer )
1734  {
1735  if ( eUpdateRefMode == URM_MOVE )
1736  { // source range
1737  nCol1 = sal::static_int_cast<SCCOL>( nCol1 - nDx );
1738  nRow1 = sal::static_int_cast<SCROW>( nRow1 - nDy );
1739  nCol2 = sal::static_int_cast<SCCOL>( nCol2 - nDx );
1740  nRow2 = sal::static_int_cast<SCROW>( nRow2 - nDy );
1741  }
1742  pDrawLayer->MoveArea( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy,
1743  (eUpdateRefMode == URM_INSDEL), bUpdateNoteCaptionPos );
1744  }
1745 }
1746 
1748  sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, bool bIncludeDraw, bool bUpdateNoteCaptionPos )
1749 {
1750  bool bUpdated = false;
1751  SCCOL i;
1752  SCCOL iMax;
1753  if (rCxt.meMode == URM_COPY )
1754  {
1755  i = rCxt.maRange.aStart.Col();
1756  iMax = rCxt.maRange.aEnd.Col();
1757  }
1758  else
1759  {
1760  i = 0;
1761  iMax = rDocument.MaxCol();
1762  }
1763 
1764  UpdateRefMode eUpdateRefMode = rCxt.meMode;
1765  SCCOL nDx = rCxt.mnColDelta;
1766  SCROW nDy = rCxt.mnRowDelta;
1767  SCTAB nDz = rCxt.mnTabDelta;
1768  SCCOL nCol1 = rCxt.maRange.aStart.Col(), nCol2 = rCxt.maRange.aEnd.Col();
1769  SCROW nRow1 = rCxt.maRange.aStart.Row(), nRow2 = rCxt.maRange.aEnd.Row();
1770  SCTAB nTab1 = rCxt.maRange.aStart.Tab(), nTab2 = rCxt.maRange.aEnd.Tab();
1771 
1772  // Named expressions need to be updated before formulas accessing them.
1773  if (mpRangeName)
1774  mpRangeName->UpdateReference(rCxt, nTab);
1775 
1776  for ( ; i<=iMax; i++)
1777  bUpdated |= CreateColumnIfNotExists(i).UpdateReference(rCxt, pUndoDoc);
1778 
1779  if ( bIncludeDraw )
1780  UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos );
1781 
1782  if ( nTab >= nTab1 && nTab <= nTab2 && nDz == 0 ) // print ranges: only within the table
1783  {
1784  SCTAB nSTab = nTab;
1785  SCTAB nETab = nTab;
1786  SCCOL nSCol = 0;
1787  SCROW nSRow = 0;
1788  SCCOL nECol = 0;
1789  SCROW nERow = 0;
1790  bool bRecalcPages = false;
1791 
1792  for ( auto& rPrintRange : aPrintRanges )
1793  {
1794  nSCol = rPrintRange.aStart.Col();
1795  nSRow = rPrintRange.aStart.Row();
1796  nECol = rPrintRange.aEnd.Col();
1797  nERow = rPrintRange.aEnd.Row();
1798 
1799  // do not try to modify sheet index of print range
1800  if ( ScRefUpdate::Update( &rDocument, eUpdateRefMode,
1801  nCol1,nRow1,nTab, nCol2,nRow2,nTab,
1802  nDx,nDy,0,
1803  nSCol,nSRow,nSTab, nECol,nERow,nETab ) )
1804  {
1805  rPrintRange = ScRange( nSCol, nSRow, 0, nECol, nERow, 0 );
1806  bRecalcPages = true;
1807  }
1808  }
1809 
1810  if ( pRepeatColRange )
1811  {
1812  nSCol = pRepeatColRange->aStart.Col();
1813  nSRow = pRepeatColRange->aStart.Row();
1814  nECol = pRepeatColRange->aEnd.Col();
1815  nERow = pRepeatColRange->aEnd.Row();
1816 
1817  // do not try to modify sheet index of repeat range
1818  if ( ScRefUpdate::Update( &rDocument, eUpdateRefMode,
1819  nCol1,nRow1,nTab, nCol2,nRow2,nTab,
1820  nDx,nDy,0,
1821  nSCol,nSRow,nSTab, nECol,nERow,nETab ) )
1822  {
1823  *pRepeatColRange = ScRange( nSCol, nSRow, 0, nECol, nERow, 0 );
1824  bRecalcPages = true;
1825  nRepeatStartX = nSCol; // for UpdatePageBreaks
1826  nRepeatEndX = nECol;
1827  }
1828  }
1829 
1830  if ( pRepeatRowRange )
1831  {
1832  nSCol = pRepeatRowRange->aStart.Col();
1833  nSRow = pRepeatRowRange->aStart.Row();
1834  nECol = pRepeatRowRange->aEnd.Col();
1835  nERow = pRepeatRowRange->aEnd.Row();
1836 
1837  // do not try to modify sheet index of repeat range
1838  if ( ScRefUpdate::Update( &rDocument, eUpdateRefMode,
1839  nCol1,nRow1,nTab, nCol2,nRow2,nTab,
1840  nDx,nDy,0,
1841  nSCol,nSRow,nSTab, nECol,nERow,nETab ) )
1842  {
1843  *pRepeatRowRange = ScRange( nSCol, nSRow, 0, nECol, nERow, 0 );
1844  bRecalcPages = true;
1845  nRepeatStartY = nSRow; // for UpdatePageBreaks
1846  nRepeatEndY = nERow;
1847  }
1848  }
1849 
1850  // updating print ranges is not necessary with multiple print ranges
1851  if ( bRecalcPages && GetPrintRangeCount() <= 1 )
1852  {
1853  UpdatePageBreaks(nullptr);
1854 
1856  }
1857  }
1858 
1859  if (bUpdated)
1860  SetStreamValid(false);
1861 
1862  if(mpCondFormatList)
1863  mpCondFormatList->UpdateReference(rCxt);
1864 
1865  if (pTabProtection)
1866  pTabProtection->updateReference( eUpdateRefMode, rDocument, rCxt.maRange, nDx, nDy, nDz);
1867 }
1868 
1869 void ScTable::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
1870  ScDocument* pUndoDoc )
1871 {
1872  for (auto const & rpCol : aCol)
1873  rpCol->UpdateTranspose( rSource, rDest, pUndoDoc );
1874 }
1875 
1876 void ScTable::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
1877 {
1878  for (auto const & rpCol : aCol)
1879  rpCol->UpdateGrow( rArea, nGrowX, nGrowY );
1880 }
1881 
1883 {
1884  // Store the old tab number in sc::UpdatedRangeNames for
1885  // ScTokenArray::AdjustReferenceOnInsertedTab() to check with
1886  // isNameModified()
1887  if (mpRangeName)
1888  mpRangeName->UpdateInsertTab(rCxt, nTab);
1889 
1890  if (nTab >= rCxt.mnInsertPos)
1891  {
1892  nTab += rCxt.mnSheets;
1893  if (pDBDataNoName)
1894  pDBDataNoName->UpdateMoveTab(nTab - 1 ,nTab);
1895  }
1896 
1897  if (mpCondFormatList)
1898  mpCondFormatList->UpdateInsertTab(rCxt);
1899 
1900  if (pTabProtection)
1901  pTabProtection->updateReference( URM_INSDEL, rDocument,
1903  0, 0, rCxt.mnSheets);
1904 
1905  for (SCCOL i=0; i < aCol.size(); i++)
1906  aCol[i].UpdateInsertTab(rCxt);
1907 
1908  SetStreamValid(false);
1909 }
1910 
1912 {
1913  // Store the old tab number in sc::UpdatedRangeNames for
1914  // ScTokenArray::AdjustReferenceOnDeletedTab() to check with
1915  // isNameModified()
1916  if (mpRangeName)
1917  mpRangeName->UpdateDeleteTab(rCxt, nTab);
1918 
1919  if (nTab > rCxt.mnDeletePos)
1920  {
1921  nTab -= rCxt.mnSheets;
1922  if (pDBDataNoName)
1923  pDBDataNoName->UpdateMoveTab(nTab + 1,nTab);
1924  }
1925 
1926  if (mpCondFormatList)
1927  mpCondFormatList->UpdateDeleteTab(rCxt);
1928 
1929  if (pTabProtection)
1930  pTabProtection->updateReference( URM_INSDEL, rDocument,
1932  0, 0, -rCxt.mnSheets);
1933 
1934  for (SCCOL i = 0; i < aCol.size(); ++i)
1935  aCol[i].UpdateDeleteTab(rCxt);
1936 
1937  SetStreamValid(false);
1938 }
1939 
1941  sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress )
1942 {
1943  nTab = nTabNo;
1944  if (mpRangeName)
1945  mpRangeName->UpdateMoveTab(rCxt, nTab);
1946 
1947  if (pDBDataNoName)
1948  pDBDataNoName->UpdateMoveTab(rCxt.mnOldPos, rCxt.mnNewPos);
1949 
1950  if(mpCondFormatList)
1951  mpCondFormatList->UpdateMoveTab(rCxt);
1952 
1953  if (pTabProtection)
1954  pTabProtection->updateReference( URM_REORDER, rDocument,
1955  ScRange( 0, 0, rCxt.mnOldPos, rDocument.MaxCol(), rDocument.MaxRow(), MAXTAB),
1956  0, 0, rCxt.mnNewPos - rCxt.mnOldPos);
1957 
1958  for ( SCCOL i=0; i < aCol.size(); i++ )
1959  {
1960  aCol[i].UpdateMoveTab(rCxt, nTabNo);
1961  if (pProgress)
1962  pProgress->SetState(pProgress->GetState() + aCol[i].GetCodeCount());
1963  }
1964 
1965  SetStreamValid(false);
1966 }
1967 
1968 void ScTable::UpdateCompile( bool bForceIfNameInUse )
1969 {
1970  for (SCCOL i=0; i < aCol.size(); i++)
1971  {
1972  aCol[i].UpdateCompile( bForceIfNameInUse );
1973  }
1974 }
1975 
1977 {
1978  nTab = nNewTab;
1979  for (SCCOL i=0; i < aCol.size(); i++)
1980  aCol[i].SetTabNo(nNewTab);
1981 }
1982 
1983 void ScTable::FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1984  sc::UpdatedRangeNames& rIndexes) const
1985 {
1986  for (SCCOL i = nCol1; i <= nCol2 && IsColValid( i ); i++)
1987  aCol[i].FindRangeNamesInUse(nRow1, nRow2, rIndexes);
1988 }
1989 
1991  SCCOL /* nStartCol */, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow )
1992 {
1993  if ( !mpColFlags || !pRowFlags )
1994  {
1995  OSL_FAIL("ExtendPrintArea: No ColInfo or RowInfo");
1996  return;
1997  }
1998 
1999  Point aPix1000 = pDev->LogicToPixel(Point(1000,1000), MapMode(MapUnit::MapTwip));
2000  double nPPTX = aPix1000.X() / 1000.0;
2001  double nPPTY = aPix1000.Y() / 1000.0;
2002 
2003  // First, mark those columns that we need to skip i.e. hidden and empty columns.
2004 
2005  ScFlatBoolColSegments aSkipCols(rDocument.MaxCol());
2006  aSkipCols.setFalse(0, rDocument.MaxCol());
2007  for (SCCOL i = 0; i <= rDocument.MaxCol(); ++i)
2008  {
2009  SCCOL nLastCol = i;
2010  if (ColHidden(i, nullptr, &nLastCol))
2011  {
2012  // Columns are hidden in this range.
2013  aSkipCols.setTrue(i, nLastCol);
2014  }
2015  else
2016  {
2017  // These columns are visible. Check for empty columns.
2018  for (SCCOL j = i; j <= nLastCol; ++j)
2019  {
2020  if ( j >= aCol.size() )
2021  {
2022  aSkipCols.setTrue( j, rDocument.MaxCol() );
2023  break;
2024  }
2025  if (aCol[j].GetCellCount() == 0)
2026  // empty
2027  aSkipCols.setTrue(j,j);
2028  }
2029  }
2030  i = nLastCol;
2031  }
2032 
2034  for (SCCOL nCol = rEndCol; nCol >= 0; --nCol)
2035  {
2036  if (!aSkipCols.getRangeData(nCol, aColData))
2037  // Failed to get the data. This should never happen!
2038  return;
2039 
2040  if (aColData.mbValue)
2041  {
2042  // Skip these columns.
2043  nCol = aColData.mnCol1; // move toward 0.
2044  continue;
2045  }
2046 
2047  // These are visible and non-empty columns.
2048  for (SCCOL nDataCol = nCol; 0 <= nDataCol && nDataCol >= aColData.mnCol1; --nDataCol)
2049  {
2050  SCCOL nPrintCol = nDataCol;
2051  VisibleDataCellIterator aIter(rDocument, *mpHiddenRows, aCol[nDataCol]);
2052  ScRefCellValue aCell = aIter.reset(nStartRow);
2053  if (aCell.isEmpty())
2054  // No visible cells found in this column. Skip it.
2055  continue;
2056 
2057  while (!aCell.isEmpty())
2058  {
2059  SCCOL nNewCol = nDataCol;
2060  SCROW nRow = aIter.getRow();
2061  if (nRow > nEndRow)
2062  // Went past the last row position. Bail out.
2063  break;
2064 
2065  MaybeAddExtraColumn(nNewCol, nRow, pDev, nPPTX, nPPTY);
2066  if (nNewCol > nPrintCol)
2067  nPrintCol = nNewCol;
2068  aCell = aIter.next();
2069  }
2070 
2071  if (nPrintCol > rEndCol)
2072  // Make sure we don't shrink the print area.
2073  rEndCol = nPrintCol;
2074  }
2075  nCol = aColData.mnCol1; // move toward 0.
2076  }
2077 }
2078 
2079 void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY)
2080 {
2081  // tdf#128873 we do not need to calculate text width (heavy operation)
2082  // when we for sure know that an additional column will not be added
2083  if (GetAllocatedColumnsCount() > rCol + 1)
2084  {
2085  ScRefCellValue aNextCell = aCol[rCol + 1].GetCellValue(nRow);
2086  if (!aNextCell.isEmpty())
2087  {
2088  // return rCol as is
2089  return;
2090  }
2091  }
2092 
2093  ScColumn& rColumn = aCol[rCol];
2094  ScRefCellValue aCell = rColumn.GetCellValue(nRow);
2095  if (!aCell.hasString())
2096  return;
2097 
2098  tools::Long nPixel = rColumn.GetTextWidth(nRow);
2099 
2100  // Width already calculated in Idle-Handler ?
2101  if ( TEXTWIDTH_DIRTY == nPixel )
2102  {
2103  ScNeededSizeOptions aOptions;
2104  aOptions.bTotalSize = true;
2105  aOptions.bFormula = false; //TODO: pass as parameter
2106  aOptions.bSkipMerged = false;
2107 
2108  Fraction aZoom(1,1);
2109  nPixel = rColumn.GetNeededSize(
2110  nRow, pDev, nPPTX, nPPTY, aZoom, aZoom, true, aOptions, nullptr );
2111 
2112  rColumn.SetTextWidth(nRow, static_cast<sal_uInt16>(nPixel));
2113  }
2114 
2115  tools::Long nTwips = static_cast<tools::Long>(nPixel / nPPTX);
2116  tools::Long nDocW = GetColWidth( rCol );
2117 
2118  tools::Long nMissing = nTwips - nDocW;
2119  if ( nMissing > 0 )
2120  {
2121  // look at alignment
2122 
2123  const ScPatternAttr* pPattern = GetPattern( rCol, nRow );
2124  const SfxItemSet* pCondSet = rDocument.GetCondResult( rCol, nRow, nTab );
2125 
2126  SvxCellHorJustify eHorJust =
2127  pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet ).GetValue();
2128  if ( eHorJust == SvxCellHorJustify::Center )
2129  nMissing /= 2; // distributed into both directions
2130  else
2131  {
2132  // STANDARD is LEFT (only text is handled here)
2133  bool bRight = ( eHorJust == SvxCellHorJustify::Right );
2134  if ( IsLayoutRTL() )
2135  bRight = !bRight;
2136  if ( bRight )
2137  nMissing = 0; // extended only to the left (logical)
2138  }
2139  }
2140 
2141  SCCOL nNewCol = rCol;
2142  while (nMissing > 0 && nNewCol < rDocument.MaxCol())
2143  {
2144  auto nNextCol = nNewCol + 1;
2145  bool bNextEmpty = true;
2146  if (GetAllocatedColumnsCount() > nNextCol)
2147  {
2148  ScRefCellValue aNextCell = aCol[nNextCol].GetCellValue(nRow);
2149  bNextEmpty = aNextCell.isEmpty();
2150  }
2151  if (!bNextEmpty)
2152  {
2153  // Cell content in a next column ends display of this string.
2154  nMissing = 0;
2155  }
2156  else
2157  nMissing -= GetColWidth(++nNewCol);
2158  }
2159  rCol = nNewCol;
2160 }
2161 
2162 namespace {
2163 
2164 class SetTableIndex
2165 {
2166  SCTAB mnTab;
2167 public:
2168  explicit SetTableIndex(SCTAB nTab) : mnTab(nTab) {}
2169 
2170  void operator() (ScRange& rRange) const
2171  {
2172  rRange.aStart.SetTab(mnTab);
2173  rRange.aEnd.SetTab(mnTab);
2174  }
2175 };
2176 
2177 }
2178 
2180 {
2181  // The table index shouldn't be used when the print range is used, but
2182  // just in case set the correct table index.
2183 
2184  aPrintRanges = rTable.aPrintRanges;
2185  ::std::for_each(aPrintRanges.begin(), aPrintRanges.end(), SetTableIndex(nTab));
2186 
2188 
2189  pRepeatColRange.reset();
2190  if (rTable.pRepeatColRange)
2191  {
2192  pRepeatColRange.reset(new ScRange(*rTable.pRepeatColRange));
2193  pRepeatColRange->aStart.SetTab(nTab);
2194  pRepeatColRange->aEnd.SetTab(nTab);
2195  }
2196 
2197  pRepeatRowRange.reset();
2198  if (rTable.pRepeatRowRange)
2199  {
2200  pRepeatRowRange.reset(new ScRange(*rTable.pRepeatRowRange));
2201  pRepeatRowRange->aStart.SetTab(nTab);
2202  pRepeatRowRange->aEnd.SetTab(nTab);
2203  }
2204 }
2205 
2206 void ScTable::SetRepeatColRange( std::unique_ptr<ScRange> pNew )
2207 {
2208  pRepeatColRange = std::move(pNew);
2209 
2210  SetStreamValid(false);
2211 
2213 }
2214 
2215 void ScTable::SetRepeatRowRange( std::unique_ptr<ScRange> pNew )
2216 {
2217  pRepeatRowRange = std::move(pNew);
2218 
2219  SetStreamValid(false);
2220 
2222 }
2223 
2225 {
2226  aPrintRanges.clear();
2227  bPrintEntireSheet = false;
2228 
2229  SetStreamValid(false);
2230 
2231  InvalidatePageBreaks(); // #i117952# forget page breaks for an old print range
2232 }
2233 
2234 void ScTable::AddPrintRange( const ScRange& rNew )
2235 {
2236  bPrintEntireSheet = false;
2237  if( aPrintRanges.size() < 0xFFFF )
2238  aPrintRanges.push_back( rNew );
2239 
2240  SetStreamValid(false);
2241 
2243 }
2244 
2246 {
2247  if( !IsPrintEntireSheet() )
2248  {
2249  ClearPrintRanges();
2250  bPrintEntireSheet = true;
2251  }
2252 }
2253 
2254 const ScRange* ScTable::GetPrintRange(sal_uInt16 nPos) const
2255 {
2256  return (nPos < GetPrintRangeCount()) ? &aPrintRanges[ nPos ] : nullptr;
2257 }
2258 
2260 {
2262  rSaveTab.SetRepeat( pRepeatColRange.get(), pRepeatRowRange.get() );
2263 }
2264 
2266 {
2267  aPrintRanges = rSaveTab.GetPrintRanges();
2268  bPrintEntireSheet = rSaveTab.IsEntireSheet();
2269  auto p = rSaveTab.GetRepeatCol();
2270  SetRepeatColRange( std::unique_ptr<ScRange>(p ? new ScRange(*p) : nullptr) );
2271  p = rSaveTab.GetRepeatRow();
2272  SetRepeatRowRange( std::unique_ptr<ScRange>(p ? new ScRange(*p) : nullptr) );
2273 
2274  InvalidatePageBreaks(); // #i117952# forget page breaks for an old print range
2275  UpdatePageBreaks(nullptr);
2276 }
2277 
2279  mrDocument(rDoc),
2280  mrRowSegs(rRowSegs),
2281  mrColumn(rColumn),
2282  mnCurRow(ROW_NOT_FOUND),
2283  mnUBound(ROW_NOT_FOUND)
2284 {
2285 }
2286 
2288 {
2289 }
2290 
2292 {
2293  if (nRow > mrDocument.MaxRow())
2294  {
2295  mnCurRow = ROW_NOT_FOUND;
2296  return ScRefCellValue();
2297  }
2298 
2300  if (!mrRowSegs.getRangeData(nRow, aData))
2301  {
2302  mnCurRow = ROW_NOT_FOUND;
2303  return ScRefCellValue();
2304  }
2305 
2306  if (!aData.mbValue)
2307  {
2308  // specified row is visible. Take it.
2309  mnCurRow = nRow;
2310  mnUBound = aData.mnRow2;
2311  }
2312  else
2313  {
2314  // specified row is not-visible. The first visible row is the start of
2315  // the next segment.
2316  mnCurRow = aData.mnRow2 + 1;
2317  mnUBound = mnCurRow; // get range data on the next iteration.
2318  if (mnCurRow > mrDocument.MaxRow())
2319  {
2320  // Make sure the row doesn't exceed our current limit.
2321  mnCurRow = ROW_NOT_FOUND;
2322  return ScRefCellValue();
2323  }
2324  }
2325 
2326  maCell = mrColumn.GetCellValue(mnCurRow);
2327  if (!maCell.isEmpty())
2328  // First visible cell found.
2329  return maCell;
2330 
2331  // Find a first visible cell below this row (if any).
2332  return next();
2333 }
2334 
2336 {
2337  if (mnCurRow == ROW_NOT_FOUND)
2338  return ScRefCellValue();
2339 
2340  while (mrColumn.GetNextDataPos(mnCurRow))
2341  {
2342  if (mnCurRow > mnUBound)
2343  {
2344  // We don't know the visibility of this row range. Query it.
2346  if (!mrRowSegs.getRangeData(mnCurRow, aData))
2347  {
2348  mnCurRow = ROW_NOT_FOUND;
2349  return ScRefCellValue();
2350  }
2351 
2352  if (aData.mbValue)
2353  {
2354  // This row is invisible. Skip to the last invisible row and
2355  // try again.
2356  mnCurRow = mnUBound = aData.mnRow2;
2357  continue;
2358  }
2359 
2360  // This row is visible.
2361  mnUBound = aData.mnRow2;
2362  }
2363 
2364  maCell = mrColumn.GetCellValue(mnCurRow);
2365  if (!maCell.isEmpty())
2366  return maCell;
2367  }
2368 
2369  mnCurRow = ROW_NOT_FOUND;
2370  return ScRefCellValue();
2371 }
2372 
2373 void ScTable::SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData)
2374 {
2375  pDBDataNoName = std::move(pDBData);
2376 }
2377 
2378 sal_uLong ScTable::AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew )
2379 {
2380  if(!mpCondFormatList)
2382 
2383  sal_uInt32 nMax = mpCondFormatList->getMaxKey();
2384 
2385  pNew->SetKey(nMax+1);
2386  mpCondFormatList->InsertNew(std::move(pNew));
2387 
2388  return nMax + 1;
2389 }
2390 
2392 {
2393  if ( !IsColValid( nCol ) )
2394  return SvtScriptType::NONE;
2395 
2396  return aCol[nCol].GetScriptType(nRow);
2397 }
2398 
2400 {
2401  if (!ValidCol(nCol))
2402  return;
2403 
2404  aCol[nCol].SetScriptType(nRow, nType);
2405 }
2406 
2408  sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 )
2409 {
2410  if ( !IsColValid( nCol ) )
2411  return SvtScriptType::NONE;
2412 
2413  sc::CellStoreType::iterator itr = aCol[nCol].maCells.begin();
2414  return aCol[nCol].GetRangeScriptType(rBlockPos.miCellTextAttrPos, nRow1, nRow2, itr);
2415 }
2416 
2418 {
2419  if ( !ValidCol( nCol ) || !ValidRow( nRow ) )
2420  return formula::FormulaTokenRef();
2421  if ( nCol >= aCol.size() )
2422  // Return a value of 0.0 if column not exists
2424  return aCol[nCol].ResolveStaticReference(nRow);
2425 }
2426 
2428 {
2429  if (nCol2 < nCol1 || nRow2 < nRow1)
2430  return formula::FormulaTokenRef();
2431 
2432  if ( !ValidCol( nCol1 ) || !ValidCol( nCol2 ) || !ValidRow( nRow1 ) || !ValidRow( nRow2 ) )
2433  return formula::FormulaTokenRef();
2434 
2435  SCCOL nMaxCol;
2436  if ( nCol2 >= aCol.size() )
2437  nMaxCol = aCol.size() - 1;
2438  else
2439  nMaxCol = nCol2;
2440 
2441  ScMatrixRef pMat(new ScMatrix(nCol2-nCol1+1, nRow2-nRow1+1, 0.0));
2442  for (SCCOL nCol = nCol1; nCol <= nMaxCol; ++nCol)
2443  {
2444  if (!aCol[nCol].ResolveStaticReference(*pMat, nCol2-nCol1, nRow1, nRow2))
2445  // Column contains non-static cell. Failed.
2446  return formula::FormulaTokenRef();
2447  }
2448 
2449  return formula::FormulaTokenRef(new ScMatrixToken(pMat));
2450 }
2451 
2453 {
2454  if (nRow2 < nRow1)
2455  return formula::VectorRefArray();
2456 
2457  if ( !IsColValid( nCol ) || !ValidRow( nRow1 ) || !ValidRow( nRow2 ) )
2458  return formula::VectorRefArray();
2459 
2460  return aCol[nCol].FetchVectorRefArray(nRow1, nRow2);
2461 }
2462 
2463 #ifdef DBG_UTIL
2465 {
2466  assert( nRow2 >= nRow1 );
2467  assert( IsColValid( nCol ) && ValidRow( nRow1 ) && ValidRow( nRow2 ) );
2468  return aCol[nCol].AssertNoInterpretNeeded(nRow1, nRow2);
2469 }
2470 #endif
2471 
2473 {
2474  if (nRow2 < nRow1)
2475  return false;
2476 
2477  if ( !IsColValid( nCol ) || !ValidRow( nRow1 ) || !ValidRow( nRow2 ) )
2478  return false;
2479 
2480  mpHiddenCols->makeReady();
2481  mpHiddenRows->makeReady();
2482  mpFilteredCols->makeReady();
2483  mpFilteredRows->makeReady();
2484 
2485  return aCol[nCol].HandleRefArrayForParallelism(nRow1, nRow2, mxGroup);
2486 }
2487 
2489 {
2490  if ( !IsColRowValid( nCol, nRow ) )
2491  return ScRefCellValue();
2492 
2493  return aCol[nCol].GetCellValue(nRow);
2494 }
2495 
2497 {
2498  if ( !IsColRowValid( nCol, nRow ) )
2499  return ScRefCellValue();
2500 
2501  return aCol[nCol].GetCellValue(rBlockPos, nRow);
2502 }
2503 
2505 {
2506  if ( !IsColRowValid( nCol, nRow ) )
2507  return nullptr;
2508 
2509  return aCol[nCol].GetBroadcaster(nRow);
2510 }
2511 
2513  sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 )
2514 {
2515  if ( !IsColValid( nCol ) )
2516  return;
2517 
2518  aCol[nCol].DeleteBroadcasters(rBlockPos, nRow1, nRow2);
2519 }
2520 
2521 void ScTable::FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const
2522 {
2523  size_t nMatCol = 0;
2524  for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol, ++nMatCol)
2525  CreateColumnIfNotExists(nCol).FillMatrix(rMat, nMatCol, nRow1, nRow2, pPool);
2526 }
2527 
2528 void ScTable::InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
2529 {
2530  nCol2 = ClampToAllocatedColumns(nCol2);
2531  for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
2532  aCol[nCol].InterpretDirtyCells(nRow1, nRow2);
2533 }
2534 
2535 void ScTable::SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen )
2536 {
2537  if (!ValidCol(nCol))
2538  return;
2539 
2540  aCol[nCol].SetFormulaResults(nRow, pResults, nLen);
2541 }
2542 
2544  SCCOL nColStart, SCCOL nColEnd,
2545  SCROW nRowStart, SCROW nRowEnd,
2546  unsigned nThisThread, unsigned nThreadsTotal)
2547 {
2548  if (!ValidCol(nColStart) || !ValidCol(nColEnd))
2549  return;
2550 
2551  size_t nLen = nRowEnd - nRowStart + 1;
2552  size_t nOffset = 0;
2553  for (SCCOL nCurrCol = nColStart; nCurrCol <= nColEnd; ++nCurrCol)
2554  {
2555  aCol[nCurrCol].CalculateInThread( rContext, nRowStart, nLen, nOffset, nThisThread, nThreadsTotal );
2556  nOffset += nLen;
2557  }
2558 }
2559 
2560 void ScTable::HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen,
2561  ScInterpreter* pInterpreter)
2562 {
2563  assert(ValidCol(nColStart) && ValidCol(nColEnd));
2564 
2565  for (SCCOL nCurrCol = nColStart; nCurrCol <= nColEnd; ++nCurrCol)
2566  aCol[nCurrCol].HandleStuffAfterParallelCalculation( nRow, nLen, pInterpreter );
2567 }
2568 
2569 #if DUMP_COLUMN_STORAGE
2570 void ScTable::DumpColumnStorage( SCCOL nCol ) const
2571 {
2572  if ( !IsColValid( nCol ) )
2573  return;
2574 
2575  aCol[nCol].DumpColumnStorage();
2576 }
2577 #endif
2578 
2580 {
2581  if ( !IsColRowValid( nCol, nRow ) )
2582  return nullptr;
2583 
2584  return aCol[nCol].GetBroadcaster(nRow);
2585 }
2586 
2588 {
2589  mpCondFormatList->erase(nIndex);
2590 }
2591 
2593 {
2594  mpCondFormatList.reset( pNew );
2595 }
2596 
2598 {
2599  if(!mpCondFormatList)
2601 
2602  return mpCondFormatList.get();
2603 }
2604 
2606 {
2607  return mpCondFormatList.get();
2608 }
2609 
2611 {
2612  ScColContainer::ScColumnVector::const_iterator beginIter;
2613  ScColContainer::ScColumnVector::const_iterator endIter;
2614 
2615  // because the range is inclusive, some code will pass nColEnd<nColBegin to indicate an empty range
2616  if (nColEnd < nColBegin)
2617  {
2618  beginIter = aCol.end();
2619  endIter = aCol.end();
2620  }
2621  else if (nColBegin >= aCol.size())
2622  {
2623  beginIter = aCol.end();
2624  endIter = aCol.end();
2625  }
2626  else
2627  {
2628  // clamp end of range to available columns
2629  if (nColEnd >= aCol.size())
2630  nColEnd = aCol.size() - 1;
2631  beginIter = aCol.begin() + nColBegin;
2632  endIter = aCol.begin() + nColEnd + 1;
2633  }
2635 }
2636 
2637 // out-of-line the cold part of the CreateColumnIfNotExists function
2639 {
2640  // When doing multi-threaded load of, e.g. XLS files, we can hit this, which calls
2641  // into SfxItemPool::Put, in parallel with other code that calls into SfxItemPool::Put,
2642  // which is bad since that code is not thread-safe.
2643  SolarMutexGuard aGuard;
2644  const SCCOL aOldColSize = aCol.size();
2645  aCol.resize( rDocument.GetSheetLimits(), static_cast< size_t >( nScCol + 1 ) );
2646  for (SCCOL i = aOldColSize; i <= nScCol; i++)
2647  aCol[i].Init( i, nTab, rDocument, false );
2648 }
2649 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
formula::FormulaTokenRef ResolveStaticReference(SCCOL nCol, SCROW nRow)
Definition: table1.cxx:2417
static bool IsSystemRTL()
Definition: global.cxx:844
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
Definition: documen2.cxx:575
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:112
SCROW GetNextMarked(SCCOL nCol, SCROW nRow, bool bUp) const
May return -1.
Definition: markdata.cxx:601
constexpr double nPPTY
SCTAB nTab
Definition: table.hxx:204
SvxCellHorJustify
SCROW mnRowDelta
Amount and direction of movement in the row direction.
const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow) const
Definition: table2.cxx:2191
void UpdatePageBreaks(const ScRange *pUserArea)
Definition: table5.cxx:52
sal_Int64 GetHashCode() const
Definition: table1.cxx:346
sal_uLong GetWeightedCount() const
Definition: column2.cxx:3573
bool SetRowHeightRange(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight, double nPPTY, bool bApi)
Definition: table2.cxx:3185
bool bStreamValid
Definition: table.hxx:239
::boost::intrusive_ptr< ScFormulaCellGroup > ScFormulaCellGroupRef
Definition: types.hxx:43
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
sal_Int32 nIndex
ScAddress aStart
Definition: address.hxx:499
bool bVisible
void SetTextWidth(SCROW nRow, sal_uInt16 nWidth)
Definition: column2.cxx:2050
bool isForceAutoSize() const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
sal_uLong GetWeightedCount() const
Definition: table3.cxx:3598
~ScTable() COVERITY_NOEXCEPT_FALSE
Definition: table1.cxx:317
void SetLink(ScLinkMode nMode, const OUString &rDoc, const OUString &rFlt, const OUString &rOpt, const OUString &rTab, sal_uLong nRefreshDelay)
Definition: table1.cxx:412
void Init()
void DeleteConditionalFormat(sal_uLong nOldIndex)
Definition: table1.cxx:2587
void DestroySortCollator()
Definition: table3.cxx:636
std::unique_ptr< ScFlatUInt16RowSegments > mpRowHeights
Definition: table.hxx:181
SCROW Row() const
Definition: address.hxx:261
const ScRange * GetPrintRange(sal_uInt16 nPos) const
Definition: table1.cxx:2254
void UpdateGrow(const ScRange &rArea, SCCOL nGrowX, SCROW nGrowY)
Definition: table1.cxx:1876
SCCOL FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const
Definition: table1.cxx:1230
bool bLoadingRTL
Definition: table.hxx:234
void SetName(const OUString &rNewName)
Definition: table1.cxx:351
SCCOL nTableAreaX
Definition: table.hxx:199
bool GetPrintArea(SCCOL &rEndCol, SCROW &rEndRow, bool bNotes, bool bCalcHiddens=false) const
Definition: table1.cxx:577
CellTextAttrStoreType::iterator miCellTextAttrPos
void SetRowHeightOnly(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight)
Set specified row height to specified ranges.
Definition: table2.cxx:3241
void SetScenario(bool bFlag)
Definition: table1.cxx:407
sal_uInt16 getExtraHeight() const
bool isEmpty() const
Definition: cellvalue.cxx:670
void InterpretDirtyCells(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: table1.cxx:2528
void SetScriptType(SCCOL nCol, SCROW nRow, SvtScriptType nType)
Definition: table1.cxx:2399
ScScenarioFlags
Definition: global.hxx:235
sal_uInt16 GetPrintRangeCount() const
Definition: table.hxx:774
void SetPrintEntireSheet()
Marks the specified sheet to be printed completely.
Definition: table1.cxx:2245
double ny
SCCOL size() const
sal_uIntPtr sal_uLong
long Long
Context for reference update during shifting, moving or copying of cell ranges.
SvtScriptType GetScriptType(SCCOL nCol, SCROW nRow) const
Definition: table1.cxx:2391
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
SCCOL FindNextVisibleCol(SCCOL nCol, bool bRight) const
Definition: table1.cxx:1206
bool GetPrintAreaVer(SCCOL nStartCol, SCCOL nEndCol, SCROW &rEndRow, bool bNotes) const
Definition: table1.cxx:707
std::unique_ptr< ScFlatBoolColSegments > mpFilteredCols
Definition: table.hxx:187
ScColumnVector::const_iterator end() const
ScLinkMode nLinkMode
Definition: table.hxx:168
ScRefCellValue reset(SCROW nRow)
Set the start row position.
Definition: table1.cxx:2291
SCROW getRow() const
Get the current row position.
Definition: table.hxx:1336
void SetFormulaResults(SCCOL nCol, SCROW nRow, const double *pResults, size_t nLen)
Definition: table1.cxx:2535
OUString aLinkFlt
Definition: table.hxx:164
Store position data for column array storage.
ScAddress aEnd
Definition: address.hxx:500
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
void UpdateReference(sc::RefUpdateContext &rCxt, ScDocument *pUndoDoc=nullptr, bool bIncludeDraw=true, bool bUpdateNoteCaptionPos=true)
Definition: table1.cxx:1747
bool bVisible
Definition: table.hxx:238
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
RowHeightsArray & getHeightArray()
void SetLoadingRTL(bool bSet)
Definition: table1.cxx:392
mdds::multi_type_vector< CellFunc, CellStoreEvent > CellStoreType
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5205
void LimitChartArea(SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow) const
Definition: table1.cxx:1181
std::unique_ptr< ScRangeName > mpRangeName
Definition: table.hxx:226
bool IsAdjustHeightLocked() const
Definition: document.hxx:1539
void MoveArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCCOL nDx, SCROW nDy, bool bInsDel, bool bUpdateNoteCaptionPos)
Definition: drwlayer.cxx:1428
SCROW nTableAreaVisibleY
Definition: table.hxx:202
bool bTableAreaVisibleValid
Definition: table.hxx:237
void MaybeAddExtraColumn(SCCOL &rCol, SCROW nRow, OutputDevice *pDev, double nPPTX, double nPPTY)
In case the cell text goes beyond the column width, move the max column position to the right...
Definition: table1.cxx:2079
void SetRepeatColRange(std::unique_ptr< ScRange > pNew)
Definition: table1.cxx:2206
bool IsCellMarked(SCCOL nCol, SCROW nRow, bool bNoSimple=false) const
Definition: markdata.cxx:285
ScRangeVec aPrintRanges
Definition: table.hxx:214
void FillPrintSaver(ScPrintSaverTab &rSaveTab) const
Definition: table1.cxx:2259
bool ValidRow(SCROW nRow) const
Definition: table.hxx:331
void GetMarkArea(ScRange &rRange) const
Definition: markdata.cxx:112
void SetStreamValid(bool bSet, bool bIgnoreLock=false)
Definition: table1.cxx:374
ScColumn & CreateColumnIfNotExists(const SCCOL nScCol) const
Definition: table.hxx:285
void CalculateInColumnInThread(ScInterpreterContext &rContext, SCCOL nColStart, SCCOL nColEnd, SCROW nRowStart, SCROW nRowEnd, unsigned nThisThread, unsigned nThreadsTotal)
Definition: table1.cxx:2543
void RepaintRange(const ScRange &rRange)
Definition: documen8.cxx:690
#define STD_COL_WIDTH
Definition: global.hxx:94
void UpdateDrawRef(UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos=true)
Definition: table1.cxx:1725
ScRefCellValue GetCellValue(SCROW nRow) const
Definition: column.cxx:733
bool ValidNextPos(SCCOL nCol, SCROW nRow, const ScMarkData &rMark, bool bMarked, bool bUnprotected) const
Definition: table1.cxx:1355
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:872
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
void SetAnonymousDBData(std::unique_ptr< ScDBData > pDBData)
Definition: table1.cxx:2373
This is a rather odd datastructure.
Definition: markarr.hxx:43
void FillMatrix(ScMatrix &rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool *pPool) const
Definition: table1.cxx:2521
bool IsMultiMarked() const
Definition: markdata.hxx:82
bool hasString() const
Definition: cellvalue.cxx:617
void ClearPrintRanges()
Removes all print ranges.
Definition: table1.cxx:2224
#define STD_EXTRA_WIDTH
Definition: global.hxx:95
SC_DLLPUBLIC bool IsDocVisible() const
Definition: document.hxx:1556
const ScRange * GetRepeatRow() const
Definition: prnsave.hxx:45
bool setFalse(SCCOL nCol1, SCCOL nCol2)
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25
void HandleStuffAfterParallelCalculation(SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, ScInterpreter *pInterpreter)
Definition: table1.cxx:2560
ScLinkMode
Definition: global.hxx:224
SCTAB Tab() const
Definition: address.hxx:270
SCROW nRepeatStartY
Definition: table.hxx:175
ScRefCellValue next()
Find the next visible data cell position.
Definition: table1.cxx:2335
ScColumnVector::const_iterator begin() const
void SetPendingRowHeights(bool bSet)
Definition: table1.cxx:382
void FindAreaPos(SCCOL &rCol, SCROW &rRow, ScMoveDirection eDirection) const
Definition: table1.cxx:1293
std::unique_ptr< ScOutlineTable > pOutlineTable
Definition: table.hxx:195
sal_uInt16 GetOptimalColWidth(SCCOL nCol, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bFormula, const ScMarkData *pMarkData, const ScColWidthParam *pParam)
Definition: table1.cxx:426
bool SkipRow(const SCCOL rCol, SCROW &rRow, const SCROW nMovY, const ScMarkData &rMark, const bool bUp, const SCROW nUsedY, const bool bMarked, const bool bSheetProtected) const
Definition: table1.cxx:1391
std::unique_ptr< ScBitMaskCompressedArray< SCCOL, CRFlags > > mpColFlags
Definition: table.hxx:183
void SetRepeatRowRange(std::unique_ptr< ScRange > pNew)
Definition: table1.cxx:2215
VisibleDataCellIterator(const ScDocument &rDoc, ScFlatBoolRowSegments &rRowSegs, ScColumn &rColumn)
Definition: table1.cxx:2278
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:70
void PutInOrder(T &nStart, T &nEnd)
Definition: address.hxx:953
bool IsLayoutRTL() const
Definition: table.hxx:340
std::unique_ptr< utl::TextSearch > pSearchText
Definition: table.hxx:206
bool IsColValid(const SCCOL nScCol) const
Definition: table.hxx:318
constexpr OUStringLiteral aData
constexpr double nPPTX
void SetRepeat(const ScRange *pCol, const ScRange *pRow)
Definition: prnsave.cxx:44
bool UpdateReference(sc::RefUpdateContext &rCxt, ScDocument *pUndoDoc)
Update reference addresses in formula cell in response to mass cell movement.
Definition: column.cxx:2479
static SC_DLLPUBLIC sal_uInt16 nStdRowHeight
Definition: global.hxx:583
std::unique_ptr< ScFlatBoolColSegments > mpHiddenCols
Definition: table.hxx:185
SCSIZE GetEmptyLinesInBlock(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScDirection eDir) const
Definition: table1.cxx:1115
void SetTab(SCTAB nTabP)
Definition: address.hxx:282
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1058
bool ShrinkToUsedDataArea(bool &o_bShrunk, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bColumnsOnly, bool bStickyTopRow, bool bStickyLeftCol, bool bConsiderCellNotes, bool bConsiderCellDrawObjects, bool bConsiderCellPatterns) const
Definition: table1.cxx:977
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:871
bool ColHidden(SCCOL nCol, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: table5.cxx:571
bool IsProtected() const
Definition: table5.cxx:1088
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4476
SvtScriptType
bool ValidCol(SCCOL nCol) const
Definition: table.hxx:330
Keep track of all named expressions that have been updated during reference update.
void AssertNoInterpretNeeded(SCCOL nCol, SCROW nRow1, SCROW nRow2)
Definition: table1.cxx:2464
bool IsMarked() const
Definition: markdata.hxx:81
void FillMatrix(ScMatrix &rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, svl::SharedStringPool *pPool) const
Definition: column2.cxx:2439
#define nPixel
void SetOptimalHeightOnly(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, ScProgress *pOuterProgress=nullptr, sal_uLong nProgressStart=0)
Definition: table1.cxx:489
int i
void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::UpdatedRangeNames &rIndexes) const
Definition: table1.cxx:1983
std::unique_ptr< ScRange > pRepeatColRange
Definition: table.hxx:216
UpdateRefMode meMode
update mode - insert/delete, copy, or move.
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: address.hxx:405
ScMoveDirection
Definition: global.hxx:334
void RestorePrintRanges(const ScPrintSaverTab &rSaveTab)
Definition: table1.cxx:2265
void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt)
Definition: table1.cxx:1882
sal_Int16 SCCOL
Definition: types.hxx:21
sal_uInt16 GetColWidth(SCCOL nCol, bool bHiddenAsZero=true) const
Definition: table2.cxx:3267
OUString aUpperName
Definition: table.hxx:208
bool GetPrintAreaHor(SCROW nStartRow, SCROW nEndRow, SCCOL &rEndCol) const
Definition: table1.cxx:670
std::unique_ptr< ScDBData > pDBDataNoName
Definition: table.hxx:225
void CreateColumnIfNotExistsImpl(const SCCOL nScCol) const
Definition: table1.cxx:2638
OUString aLinkDoc
Definition: table.hxx:163
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:873
void UpdateCompile(bool bForceIfNameInUse=false)
Definition: table1.cxx:1968
void AddPrintRange(const ScRange &rNew)
Adds a new print ranges.
Definition: table1.cxx:2234
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
const mdds::mtv::element_t element_type_empty
Definition: mtvelements.hxx:55
::boost::intrusive_ptr< FormulaToken > FormulaTokenRef
std::unique_ptr< ScTableProtection > pTabProtection
Definition: table.hxx:178
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
bool ScAddPage(SCTAB nTab)
Definition: drwlayer.cxx:380
ScMarkArray GetMarkArray(SCCOL nCol) const
Definition: markdata.cxx:942
ScRefCellValue GetRefCellValue(SCCOL nCol, SCROW nRow)
Definition: table1.cxx:2488
void GetLastDataPos(SCCOL &rCol, SCROW &rRow) const
Definition: table2.cxx:1952
const ScRangeVec & GetPrintRanges() const
Definition: prnsave.hxx:42
bool GetNextMarkedCell(SCCOL &rCol, SCROW &rRow, const ScMarkData &rMark) const
Definition: table1.cxx:1673
bool bTableAreaValid
Definition: table.hxx:236
OUString aName
Definition: table.hxx:159
ScColContainer aCol
Definition: table.hxx:157
sal_uLong GetState() const
Definition: progress.hxx:109
bool GetTableArea(SCCOL &rEndCol, SCROW &rEndRow, bool bCalcHiddens=false) const
Definition: table1.cxx:549
std::unique_ptr< ScConditionalFormatList > mpCondFormatList
Definition: table.hxx:228
Color aTabBgColor
Definition: table.hxx:223
tools::Long GetNeededSize(SCROW nRow, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bWidth, const ScNeededSizeOptions &rOptions, const ScPatternAttr **pPatternChange, bool bInPrintTwips=false) const
Definition: column2.cxx:80
SvtScriptType GetRangeScriptType(sc::ColumnBlockPosition &rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2)
Definition: table1.cxx:2407
void UpdateTranspose(const ScRange &rSource, const ScAddress &rDest, ScDocument *pUndoDoc)
Definition: table1.cxx:1869
const SCCOL SC_COLUMNS_STOP
Definition: table1.cxx:575
void SetValue(A nPos, const D &rValue)
const SCTAB MAXTAB
Definition: address.hxx:70
const ScRange * GetRepeatCol() const
Definition: prnsave.hxx:44
SC_DLLPUBLIC const SfxItemSet * GetCondResult(SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue *pCell=nullptr) const
Definition: documen4.cxx:789
void SetTabNo(SCTAB nNewTab)
Definition: table1.cxx:1976
ScTable(ScDocument &rDoc, SCTAB nNewTab, const OUString &rNewName, bool bColInfo=true, bool bRowInfo=true)
Definition: table1.cxx:235
double getPPTY() const
ScRange maRange
Range of cells that are about to be moved for insert/delete/move modes.
const SCROW SCROW_REPEAT_NONE
Definition: address.hxx:87
bool bLayoutRTL
Definition: table.hxx:233
bool IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const
Definition: table1.cxx:1166
SCCOL Col() const
Definition: address.hxx:266
SCCOL nTableAreaVisibleX
Definition: table.hxx:201
void SetCondFormList(ScConditionalFormatList *pList)
Definition: table1.cxx:2592
void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt, SCTAB nTabNo, ScProgress *pProgress)
Definition: table1.cxx:1940
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
bool GetDataAreaSubrange(ScRange &rRange) const
Definition: table1.cxx:936
void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt)
Definition: table1.cxx:1911
const D & GetValue(A nPos) const
void InvalidatePageBreaks()
Definition: table2.cxx:1530
void GetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart)
Definition: column2.cxx:816
bool IsInDtorClear() const
Definition: document.hxx:2365
void SetState(sal_uLong nVal, sal_uLong nNewRange=0)
Definition: progress.hxx:78
OUString aLinkOpt
Definition: table.hxx:165
SCCOL nRepeatEndX
Definition: table.hxx:174
bool RowHidden(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: table5.cxx:496
UpdateRefMode
Definition: global.hxx:309
tools::Long GetNeededSize(SCCOL nCol, SCROW nRow, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bWidth, bool bTotalSize, bool bInPrintTwips=false)
Definition: table1.cxx:439
CRFlags
Definition: global.hxx:134
sal_Int32 SCROW
Definition: types.hxx:17
void SetPageSize(sal_uInt16 nPageNo, const Size &rSize, bool bUpdateNoteCaptionPos, const ScObjectHandling eObjectHandling=ScObjectHandling::RecalcPosMode)
Definition: drwlayer.cxx:563
void SetTabBgColor(const Color &rColor)
Definition: table1.cxx:397
bool IsColRowValid(const SCCOL nScCol, const SCROW nScRow) const
Definition: table.hxx:322
bool IsPrintEntireSheet() const
Returns true, if the sheet is always printed.
Definition: table.hxx:777
OUString ScResId(std::string_view aId)
Definition: scdll.cxx:89
std::unique_ptr< ScFlatBoolRowSegments > mpFilteredRows
Definition: table.hxx:188
void ScRenamePage(SCTAB nTab, const OUString &rNewName)
Definition: drwlayer.cxx:412
const SCCOL INITIALCOLCOUNT
Definition: address.hxx:64
double nx
bool IsEntireSheet() const
Definition: prnsave.hxx:43
void GetDataArea(SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bIncludeOld, bool bOnlyDown) const
Definition: table1.cxx:813
SCROW nRepeatEndY
Definition: table.hxx:176
SCROW GetLastDataRow(SCCOL nCol1, SCCOL nCol2, SCROW nLastRow, bool bConsiderCellNotes=false, bool bConsiderCellDrawObjects=false, bool bConsiderCellPatterns=false) const
Definition: table1.cxx:1095
bool ValidColRow(SCCOL nCol, SCROW nRow) const
Definition: table.hxx:332
SCTAB mnTabDelta
Amount and direction of movement in the sheet direction.
void SetLayoutRTL(bool bSet)
Definition: table1.cxx:387
RangeData GetRangeData(A nPos) const
Get range data for a row, i.e.
sal_uLong GetCellCount() const
Definition: table3.cxx:3588
OUString aName
void DumpColumnStorage(SCCOL nCol) const
ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const
Definition: table1.cxx:2610
bool GetCellArea(SCCOL &rEndCol, SCROW &rEndRow) const
Definition: table1.cxx:513
void DeleteBroadcasters(sc::ColumnBlockPosition &rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2)
Definition: table1.cxx:2512
void SetVisible(bool bVis)
Definition: table1.cxx:366
bool bPendingRowHeights
Definition: table.hxx:240
formula::VectorRefArray FetchVectorRefArray(SCCOL nCol, SCROW nRow1, SCROW nRow2)
Definition: table1.cxx:2452
std::unique_ptr< ScCompressedArray< SCCOL, sal_uInt16 > > mpColWidth
Definition: table.hxx:180
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
bool HandleRefArrayForParallelism(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScFormulaCellGroupRef &mxGroup)
Definition: table1.cxx:2472
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
Definition: global.cxx:1009
void * p
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:400
SvtBroadcaster * GetBroadcaster(SCCOL nCol, SCROW nRow)
Definition: table1.cxx:2504
SCROW nTableAreaY
Definition: table.hxx:200
SCROW GetNextUnprotected(SCROW nRow, bool bUp) const
Including current, may return -1.
Definition: attarray.cxx:1770
const ScColumn & back() const
void CopyPrintRange(const ScTable &rTable)
Definition: table1.cxx:2179
SCCOL nRepeatStartX
Definition: table.hxx:173
std::unique_ptr< ScRange > pRepeatRowRange
Definition: table.hxx:217
std::unique_ptr< ScRangeList > pScenarioRanges
Definition: table.hxx:221
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1057
The data type represents bits, manageable by bitwise operations.
ScDirection
Definition: global.hxx:351
const SCCOL SC_TABSTART_NONE
Definition: address.hxx:88
void GetMultiMarkArea(ScRange &rRange) const
Definition: markdata.cxx:117
OUString aLinkTab
Definition: table.hxx:166
SCCOL ClampToAllocatedColumns(SCCOL nCol) const
Definition: table.hxx:1096
void resize(ScSheetLimits const &, const size_t aNewSize)
ScDocument & rDocument
Definition: table.hxx:205
bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi, ScProgress *pOuterProgress=nullptr, sal_uLong nProgressStart=0)
Definition: table1.cxx:456
sal_uLong AddCondFormat(std::unique_ptr< ScConditionalFormat > pNew)
Definition: table1.cxx:2378
void GetNextPos(SCCOL &rCol, SCROW &rRow, SCCOL nMovX, SCROW nMovY, bool bMarked, bool bUnprotected, const ScMarkData &rMark, SCCOL nTabStartCol) const
Definition: table1.cxx:1428
SCCOL mnColDelta
Amount and direction of movement in the column direction.
bool bPrintEntireSheet
Definition: table.hxx:243
std::unique_ptr< ScFlatBoolRowSegments > mpHiddenRows
Definition: table.hxx:186
sal_uInt16 GetTextWidth(SCROW nRow) const
Definition: column2.cxx:2045
SCCOL GetAllocatedColumnsCount() const
Definition: table.hxx:1097
const OUString & GetUpperName() const
Definition: table1.cxx:359
std::unique_ptr< ScSheetEvents > pSheetEvents
Definition: table.hxx:197
void ExtendPrintArea(OutputDevice *pDev, SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW nEndRow)
Definition: table1.cxx:1990
void ScRemovePage(SCTAB nTab)
Definition: drwlayer.cxx:394
ScAttrArray aDefaultColAttrArray
Definition: table.hxx:249
SCROW GetNextMarked(SCROW nRow, bool bUp) const
Including current row, may return -1 if bUp and not found.
Definition: markarr.cxx:290
bool IsStreamValidLocked() const
Definition: document.hxx:965
sal_uLong nLinkRefreshDelay
Definition: table.hxx:167
const SCCOL SCCOL_REPEAT_NONE
Definition: address.hxx:86
Use this to iterate through non-empty visible cells in a single column.
Definition: table.hxx:1306
bool bScenario
Definition: table.hxx:232
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:22
void SetAreas(const ScRangeVec &rRanges, bool bEntireSheet)
Definition: prnsave.cxx:38
bool GetDataStart(SCCOL &rStartCol, SCROW &rStartRow) const
Definition: table1.cxx:751
#define TEXTWIDTH_DIRTY
Definition: globalnames.hxx:17
ScConditionalFormatList * GetCondFormList()
Definition: table1.cxx:2597