LibreOffice Module sc (master)  1
viewfun2.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 eCode 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 
22 #include <sfx2/app.hxx>
23 #include <editeng/borderline.hxx>
24 #include <editeng/boxitem.hxx>
25 #include <editeng/fontitem.hxx>
26 #include <editeng/lineitem.hxx>
28 #include <svl/srchitem.hxx>
29 #include <sfx2/linkmgr.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/docfilt.hxx>
32 #include <sfx2/docfile.hxx>
33 #include <sfx2/objitem.hxx>
34 #include <sfx2/viewfrm.hxx>
35 #include <svl/numformat.hxx>
36 #include <svl/stritem.hxx>
37 #include <svl/zforlist.hxx>
38 #include <svx/srchdlg.hxx>
39 #include <svx/svdview.hxx>
40 #include <vcl/svapp.hxx>
41 #include <vcl/weld.hxx>
42 #include <osl/diagnose.h>
43 
44 #include <viewfunc.hxx>
45 #include <vcl/uitest/logger.hxx>
47 
48 #include <sc.hrc>
49 #include <globstr.hrc>
50 #include <scresid.hxx>
51 
52 #include <attrib.hxx>
53 #include <autoform.hxx>
54 #include <formulacell.hxx>
55 #include <cellmergeoption.hxx>
56 #include <compiler.hxx>
57 #include <docfunc.hxx>
58 #include <docpool.hxx>
59 #include <docsh.hxx>
60 #include <docoptio.hxx>
61 #include <global.hxx>
62 #include <patattr.hxx>
63 #include <printfun.hxx>
64 #include <refundo.hxx>
65 #include <table.hxx>
66 #include <tablink.hxx>
67 #include <tabvwsh.hxx>
68 #include <uiitems.hxx>
69 #include <undoblk.hxx>
70 #include <undotab.hxx>
71 #include <sizedev.hxx>
72 #include <editable.hxx>
73 #include <docuno.hxx>
74 #include <charthelper.hxx>
75 #include <tabbgcolor.hxx>
76 #include <clipparam.hxx>
77 #include <prnsave.hxx>
78 #include <searchresults.hxx>
79 #include <tokenarray.hxx>
80 #include <rowheightcontext.hxx>
81 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
82 #include <comphelper/lok.hxx>
83 #include <mergecellsdialog.hxx>
84 #include <sheetevents.hxx>
85 #include <columnspanset.hxx>
86 
87 #include <vector>
88 #include <memory>
89 #include <boost/property_tree/json_parser.hpp>
90 
91 #include <officecfg/Office/Calc.hxx>
92 
93 using namespace com::sun::star;
94 using ::editeng::SvxBorderLine;
95 
96 namespace {
97 
98 void collectUIInformation(std::map<OUString, OUString>&& aParameters, const OUString& rAction)
99 {
100  EventDescription aDescription;
101  aDescription.aID = "grid_window";
102  aDescription.aAction = rAction;
103  aDescription.aParameters = std::move(aParameters);
104  aDescription.aParent = "MainWindow";
105  aDescription.aKeyWord = "ScGridWinUIObject";
106 
107  UITestLogger::getInstance().logEvent(aDescription);
108 }
109 }
110 
111 using ::std::vector;
112 using ::std::unique_ptr;
113 
114 bool ScViewFunc::AdjustBlockHeight( bool bPaint, ScMarkData* pMarkData )
115 {
116  ScDocShell* pDocSh = GetViewData().GetDocShell();
117  if (!pMarkData)
118  pMarkData = &GetViewData().GetMarkData();
119 
120  ScDocument& rDoc = pDocSh->GetDocument();
121  std::vector<sc::ColRowSpan> aMarkedRows = pMarkData->GetMarkedRowSpans();
122 
123  if (aMarkedRows.empty())
124  {
125  SCROW nCurRow = GetViewData().GetCurY();
126  aMarkedRows.emplace_back(nCurRow, nCurRow);
127  }
128 
130  {
131  SCCOLROW nStart = aMarkedRows[0].mnStart;
132  OnLOKSetWidthOrHeight(nStart, /*width: */ false);
133  }
134 
135  double nPPTX = GetViewData().GetPPTX();
136  double nPPTY = GetViewData().GetPPTY();
137  Fraction aZoomX = GetViewData().GetZoomX();
138  Fraction aZoomY = GetViewData().GetZoomY();
139 
140  ScSizeDeviceProvider aProv(pDocSh);
141  if (aProv.IsPrinter())
142  {
143  nPPTX = aProv.GetPPTX();
144  nPPTY = aProv.GetPPTY();
145  aZoomX = aZoomY = Fraction( 1, 1 );
146  }
147 
148  sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
149  bool bAnyChanged = false;
150  for (const SCTAB& nTab : *pMarkData)
151  {
152  bool bChanged = false;
153  SCROW nPaintY = 0;
154  for (const auto& rRow : aMarkedRows)
155  {
156  SCROW nStartNo = rRow.mnStart;
157  SCROW nEndNo = rRow.mnEnd;
158  ScAddress aTopLeft(0, nStartNo, nTab);
159  rDoc.UpdateScriptTypes(aTopLeft, rDoc.GetSheetLimits().GetMaxColCount(), nEndNo-nStartNo+1);
160  if (rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab, true))
161  {
162  if (!bChanged)
163  nPaintY = nStartNo;
164  bAnyChanged = bChanged = true;
165  }
166  }
167  // tdf#76183: recalculate objects' positions
168  if (bChanged)
169  rDoc.SetDrawPageSize(nTab);
170  if ( bPaint && bChanged )
171  pDocSh->PostPaint( 0, nPaintY, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab,
173  }
174 
175  if ( bPaint && bAnyChanged )
176  pDocSh->UpdateOle(GetViewData());
177 
179  {
180  SCTAB nTab = GetViewData().GetTabNo();
182  GetViewData().GetViewShell(),
183  false /* bColumns */, true /* bRows */,
184  true /* bSizes*/, false /* bHidden */, false /* bFiltered */,
185  false /* bGroups */, nTab);
186  ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), ROW_HEADER, nTab);
187  }
188 
189  return bAnyChanged;
190 }
191 
192 bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, bool bApi )
193 {
195  {
196  OnLOKSetWidthOrHeight(nStartRow, /*width: */ false);
197  }
198 
199  ScDocShell* pDocSh = GetViewData().GetDocShell();
200  ScDocument& rDoc = pDocSh->GetDocument();
201  SCTAB nTab = GetViewData().GetTabNo();
202  double nPPTX = GetViewData().GetPPTX();
203  double nPPTY = GetViewData().GetPPTY();
204  Fraction aZoomX = GetViewData().GetZoomX();
205  Fraction aZoomY = GetViewData().GetZoomY();
206  sal_uInt16 nOldPixel = 0;
207  if (nStartRow == nEndRow)
208  nOldPixel = static_cast<sal_uInt16>(rDoc.GetRowHeight(nStartRow,nTab) * nPPTY);
209 
210  ScSizeDeviceProvider aProv(pDocSh);
211  if (aProv.IsPrinter())
212  {
213  nPPTX = aProv.GetPPTX();
214  nPPTY = aProv.GetPPTY();
215  aZoomX = aZoomY = Fraction( 1, 1 );
216  }
217  sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
218  bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab, bApi);
219 
220  // tdf#76183: recalculate objects' positions
221  if (bChanged)
222  rDoc.SetDrawPageSize(nTab);
223 
224  if (bChanged && ( nStartRow == nEndRow ))
225  {
226  sal_uInt16 nNewPixel = static_cast<sal_uInt16>(rDoc.GetRowHeight(nStartRow,nTab) * nPPTY);
227  if ( nNewPixel == nOldPixel )
228  bChanged = false;
229  }
230 
231  if ( bChanged )
232  pDocSh->PostPaint( 0, nStartRow, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab,
234 
236  {
238  GetViewData().GetViewShell(),
239  false /* bColumns */, true /* bRows */,
240  true /* bSizes*/, false /* bHidden */, false /* bFiltered */,
241  false /* bGroups */, nTab);
242  ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), ROW_HEADER, GetViewData().GetTabNo());
243  }
244 
245  return bChanged;
246 }
247 
248 namespace {
249 
251 {
252  ScAutoSumNone = 0,
253  ScAutoSumData,
254  ScAutoSumSum,
255  ScAutoSumAverage,
256  ScAutoSumMax,
257  ScAutoSumMin,
258  ScAutoSumCount
259 };
260 
261 }
262 
264  SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
265 {
266  ScRefCellValue aCell(rDoc, ScAddress(nCol, nRow, nTab));
267  if (aCell.hasNumeric())
268  {
269  if (aCell.meType == CELLTYPE_FORMULA)
270  {
271  ScAutoSum val = ScAutoSumNone;
272  ScTokenArray* pCode = aCell.mpFormula->GetCode();
273  if ( pCode )
274  {
275  switch( pCode->GetOuterFuncOpCode() )
276  {
277  case ocSum : val = ScAutoSumSum;
278  break;
279  case ocAverage : val = ScAutoSumAverage;
280  break;
281  case ocMax : val = ScAutoSumMax;
282  break;
283  case ocMin : val = ScAutoSumMin;
284  break;
285  case ocCount : val = ScAutoSumCount;
286  break;
287  default :
288  break;
289  }
290  if ( pCode->GetAdjacentExtendOfOuterFuncRefs( nExtend,
291  ScAddress( nCol, nRow, nTab ), eDir ) )
292  return val;
293  }
294  }
295  return ScAutoSumData;
296  }
297  return ScAutoSumNone;
298 }
299 
300 #define SC_AUTOSUM_MAXCOUNT 20
301 
302 static ScAutoSum lcl_SeekAutoSumData( ScDocument& rDoc, SCCOL& nCol, SCROW& nRow,
303  SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
304 {
305  sal_uInt16 nCount = 0;
306  while (nCount < SC_AUTOSUM_MAXCOUNT)
307  {
308  if ( eDir == DIR_TOP )
309  {
310  if (nRow > 0)
311  --nRow;
312  else
313  return ScAutoSumNone;
314  }
315  else
316  {
317  if (nCol > 0)
318  --nCol;
319  else
320  return ScAutoSumNone;
321  }
322  ScAutoSum eSum;
323  if ( (eSum = lcl_IsAutoSumData(
324  rDoc, nCol, nRow, nTab, eDir, nExtend )) != ScAutoSumNone )
325  return eSum;
326  ++nCount;
327  }
328  return ScAutoSumNone;
329 }
330 
331 #undef SC_AUTOSUM_MAXCOUNT
332 
333 static bool lcl_FindNextSumEntryInColumn( ScDocument& rDoc, SCCOL nCol, SCROW& nRow,
334  SCTAB nTab, SCCOLROW& nExtend, SCROW nMinRow )
335 {
336  const SCROW nTmp = nRow;
337  ScAutoSum eSkip = ScAutoSumNone;
338  for (;;)
339  {
340  eSkip = lcl_IsAutoSumData( rDoc, nCol, nRow, nTab, DIR_TOP, nExtend );
341  if (eSkip != ScAutoSumData || nRow <= nMinRow )
342  break;
343  --nRow;
344  }
345  return eSkip >= ScAutoSumSum && nRow < nTmp;
346 }
347 
348 static bool lcl_FindNextSumEntryInRow( ScDocument& rDoc, SCCOL& nCol, SCROW nRow,
349  SCTAB nTab, SCCOLROW& nExtend, SCCOL nMinCol )
350 {
351  const SCCOL nTmp = nCol;
352  ScAutoSum eSkip = ScAutoSumNone;
353  for (;;)
354  {
355  eSkip = lcl_IsAutoSumData( rDoc, nCol, nRow, nTab, DIR_LEFT, nExtend );
356  if (eSkip != ScAutoSumData || nCol <= nMinCol )
357  break;
358  --nCol;
359  }
360  return eSkip >= ScAutoSumSum && nCol < nTmp;
361 }
362 
363 static ScAutoSum lcl_GetAutoSumForColumnRange( ScDocument& rDoc, ScRangeList& rRangeList, const ScRange& rRange )
364 {
365  const ScAddress aStart = rRange.aStart;
366  const ScAddress aEnd = rRange.aEnd;
367  if ( aStart.Col() != aEnd.Col() )
368  {
369  return ScAutoSumNone;
370  }
371 
372  const SCTAB nTab = aEnd.Tab();
373  const SCCOL nCol = aEnd.Col();
374  SCROW nEndRow = aEnd.Row();
375  SCROW nStartRow = nEndRow;
376  SCCOLROW nExtend = 0;
377  ScAutoSum eSum = lcl_IsAutoSumData( rDoc, nCol, nEndRow, nTab, DIR_TOP, nExtend /*out*/ );
378 
379  if ( eSum >= ScAutoSumSum )
380  {
381  bool bContinue = false;
382  do
383  {
384  rRangeList.push_back( ScRange( nCol, nStartRow, nTab, nCol, nEndRow, nTab ) );
385  nEndRow = static_cast< SCROW >( nExtend );
386  bContinue = lcl_FindNextSumEntryInColumn( rDoc, nCol, nEndRow /*inout*/, nTab, nExtend /*out*/, aStart.Row() );
387  if ( bContinue )
388  {
389  nStartRow = nEndRow;
390  }
391  } while ( bContinue );
392  }
393  else
394  {
395  while ( nStartRow > aStart.Row() )
396  {
397  eSum = lcl_IsAutoSumData( rDoc, nCol, nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ );
398  if (eSum >= ScAutoSumSum )
399  break;
400  --nStartRow;
401  }
402  rRangeList.push_back( ScRange( nCol, nStartRow, nTab, nCol, nEndRow, nTab ) );
403  if (eSum == ScAutoSumNone)
404  eSum = ScAutoSumData;
405  }
406 
407  return eSum;
408 }
409 
410 static ScAutoSum lcl_GetAutoSumForRowRange( ScDocument& rDoc, ScRangeList& rRangeList, const ScRange& rRange )
411 {
412  const ScAddress aStart = rRange.aStart;
413  const ScAddress aEnd = rRange.aEnd;
414  if ( aStart.Row() != aEnd.Row() )
415  {
416  return ScAutoSumNone;
417  }
418 
419  const SCTAB nTab = aEnd.Tab();
420  const SCROW nRow = aEnd.Row();
421  SCCOL nEndCol = aEnd.Col();
422  SCCOL nStartCol = nEndCol;
423  SCCOLROW nExtend = 0;
424  ScAutoSum eSum = lcl_IsAutoSumData( rDoc, nEndCol, nRow, nTab, DIR_LEFT, nExtend /*out*/ );
425 
426  if ( eSum >= ScAutoSumSum )
427  {
428  bool bContinue = false;
429  do
430  {
431  rRangeList.push_back( ScRange( nStartCol, nRow, nTab, nEndCol, nRow, nTab ) );
432  nEndCol = static_cast< SCCOL >( nExtend );
433  bContinue = lcl_FindNextSumEntryInRow( rDoc, nEndCol /*inout*/, nRow, nTab, nExtend /*out*/, aStart.Col() );
434  if ( bContinue )
435  {
436  nStartCol = nEndCol;
437  }
438  } while ( bContinue );
439  }
440  else
441  {
442  while ( nStartCol > aStart.Col() )
443  {
444  eSum = lcl_IsAutoSumData( rDoc, nStartCol-1, nRow, nTab, DIR_LEFT, nExtend /*out*/ );
445  if (eSum >= ScAutoSumSum )
446  break;
447  --nStartCol;
448  }
449  rRangeList.push_back( ScRange( nStartCol, nRow, nTab, nEndCol, nRow, nTab ) );
450  if (eSum == ScAutoSumNone)
451  eSum = ScAutoSumData;
452  }
453 
454  return eSum;
455 }
456 
457 static sal_Int8 GetSubTotal( const OpCode eCode )
458 {
459  sal_Int8 val;
460  switch ( eCode )
461  {
462  case ocSum : val = 9;
463  break;
464  case ocAverage : val = 1;
465  break;
466  case ocMax : val = 4;
467  break;
468  case ocMin : val = 5;
469  break;
470  case ocCount : val = 2;
471  break;
472  default : val = 9;
473  }
474 
475  return val;
476 }
477 
479 {
480  ScDocument& rDoc = GetViewData().GetDocument();
481  SCTAB nTab = GetViewData().GetTabNo();
482 
483  SCCOL nCol = GetViewData().GetCurX();
484  SCROW nRow = GetViewData().GetCurY();
485 
486  SCCOL nStartCol = nCol;
487  SCROW nStartRow = nRow;
488  SCCOL nEndCol = nCol;
489  SCROW nEndRow = nRow;
490  SCCOL nSeekCol = nCol;
491  SCROW nSeekRow = nRow;
492  SCCOLROW nExtend; // will become valid via reference for ScAutoSumSum
493 
494  bool bCol = false;
495  bool bRow = false;
496 
497  ScAutoSum eSum;
498  if ( nRow != 0
499  && ((eSum = lcl_IsAutoSumData( rDoc, nCol, nRow-1, nTab,
500  DIR_TOP, nExtend /*out*/ )) == ScAutoSumData )
501  && ((eSum = lcl_IsAutoSumData( rDoc, nCol, nRow-1, nTab,
502  DIR_LEFT, nExtend /*out*/ )) == ScAutoSumData )
503  )
504  {
505  bRow = true;
506  nSeekRow = nRow - 1;
507  }
508  else if ( nCol != 0 && (eSum = lcl_IsAutoSumData( rDoc, nCol-1, nRow, nTab,
509  DIR_LEFT, nExtend /*out*/ )) == ScAutoSumData )
510  {
511  bCol = true;
512  nSeekCol = nCol - 1;
513  }
514  else if ( (eSum = lcl_SeekAutoSumData( rDoc, nCol, nSeekRow, nTab, DIR_TOP, nExtend /*out*/ )) != ScAutoSumNone )
515  bRow = true;
516  else if (( eSum = lcl_SeekAutoSumData( rDoc, nSeekCol, nRow, nTab, DIR_LEFT, nExtend /*out*/ )) != ScAutoSumNone )
517  bCol = true;
518 
519  if ( bCol || bRow )
520  {
521  if ( bRow )
522  {
523  nStartRow = nSeekRow; // nSeekRow might be adjusted via reference
524  if ( eSum >= ScAutoSumSum && eSum <= ScAutoSumCount )
525  nEndRow = nStartRow; // only sum sums
526  else
527  nEndRow = nRow - 1; // maybe extend data area at bottom
528  }
529  else
530  {
531  nStartCol = nSeekCol; // nSeekCol might be adjusted via reference
532  if ( eSum >= ScAutoSumSum )
533  nEndCol = nStartCol; // only sum sums
534  else
535  nEndCol = nCol - 1; // maybe extend data area to the right
536  }
537  bool bContinue = false;
538  do
539  {
540  if ( eSum == ScAutoSumData )
541  {
542  if ( bRow )
543  {
544  while ( nStartRow != 0 && lcl_IsAutoSumData( rDoc, nCol,
545  nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ ) == eSum )
546  --nStartRow;
547  }
548  else
549  {
550  while ( nStartCol != 0 && lcl_IsAutoSumData( rDoc, nStartCol-1,
551  nRow, nTab, DIR_LEFT, nExtend /*out*/ ) == eSum )
552  --nStartCol;
553  }
554  }
555  rRangeList.push_back(
556  ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ) );
557  if ( eSum >= ScAutoSumSum )
558  {
559  if ( bRow )
560  {
561  nEndRow = static_cast< SCROW >( nExtend );
562  bContinue = lcl_FindNextSumEntryInColumn( rDoc, nCol, nEndRow /*inout*/, nTab, nExtend /*out*/, 0 );
563  if ( bContinue )
564  {
565  nStartRow = nEndRow;
566  }
567  }
568  else
569  {
570  nEndCol = static_cast< SCCOL >( nExtend );
571  bContinue = lcl_FindNextSumEntryInRow( rDoc, nEndCol /*inout*/, nRow, nTab, nExtend /*out*/, 0 );
572  if ( bContinue )
573  {
574  nStartCol = nEndCol;
575  }
576  }
577  }
578  } while ( bContinue );
579  return true;
580  }
581  return false;
582 }
583 
584 void ScViewFunc::EnterAutoSum(const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr, const OpCode eCode)
585 {
586  OUString aFormula = GetAutoSumFormula( rRangeList, bSubTotal, rAddr , eCode);
587  EnterBlock( aFormula, nullptr );
588 }
589 
590 bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor, bool bContinue , const OpCode eCode)
591 {
592  ScDocument& rDoc = GetViewData().GetDocument();
593  const SCTAB nTab = rRange.aStart.Tab();
594  SCCOL nStartCol = rRange.aStart.Col();
595  SCROW nStartRow = rRange.aStart.Row();
596  const SCCOL nEndCol = rRange.aEnd.Col();
597  const SCROW nEndRow = rRange.aEnd.Row();
598  SCCOLROW nExtend = 0; // out parameter for lcl_IsAutoSumData
599 
600  // ignore rows at the top of the given range which don't contain autosum data
601  bool bRowData = false;
602  for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
603  {
604  for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
605  {
606  if ( lcl_IsAutoSumData( rDoc, nCol, nRow, nTab, DIR_TOP, nExtend ) != ScAutoSumNone )
607  {
608  bRowData = true;
609  break;
610  }
611  }
612  if ( bRowData )
613  {
614  nStartRow = nRow;
615  break;
616  }
617  }
618  if ( !bRowData )
619  {
620  return false;
621  }
622 
623  // ignore columns at the left of the given range which don't contain autosum data
624  bool bColData = false;
625  for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
626  {
627  for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
628  {
629  if ( lcl_IsAutoSumData( rDoc, nCol, nRow, nTab, DIR_LEFT, nExtend ) != ScAutoSumNone )
630  {
631  bColData = true;
632  break;
633  }
634  }
635  if ( bColData )
636  {
637  nStartCol = nCol;
638  break;
639  }
640  }
641  if ( !bColData )
642  {
643  return false;
644  }
645 
646  const bool bEndRowEmpty = rDoc.IsBlockEmpty( nTab, nStartCol, nEndRow, nEndCol, nEndRow );
647  const bool bEndColEmpty = rDoc.IsBlockEmpty( nTab, nEndCol, nStartRow, nEndCol, nEndRow );
648  bool bRow = ( nStartRow != nEndRow ) && ( bEndRowEmpty || !bEndColEmpty );
649  bool bCol = ( nStartCol != nEndCol ) && ( bEndColEmpty || nStartRow == nEndRow );
650 
651  // find an empty row for entering the result
652  SCROW nInsRow = nEndRow;
653  if ( bRow && !bEndRowEmpty )
654  {
655  if ( nInsRow < rDoc.MaxRow() )
656  {
657  ++nInsRow;
658  while ( !rDoc.IsBlockEmpty( nTab, nStartCol, nInsRow, nEndCol, nInsRow ) )
659  {
660  if ( nInsRow < rDoc.MaxRow() )
661  {
662  ++nInsRow;
663  }
664  else
665  {
666  bRow = false;
667  break;
668  }
669  }
670  }
671  else
672  {
673  bRow = false;
674  }
675  }
676 
677  // find an empty column for entering the result
678  SCCOL nInsCol = nEndCol;
679  if ( bCol && !bEndColEmpty )
680  {
681  if ( nInsCol < rDoc.MaxCol() )
682  {
683  ++nInsCol;
684  while ( !rDoc.IsBlockEmpty( nTab, nInsCol, nStartRow, nInsCol, nEndRow ) )
685  {
686  if ( nInsCol < rDoc.MaxCol() )
687  {
688  ++nInsCol;
689  }
690  else
691  {
692  bCol = false;
693  break;
694  }
695  }
696  }
697  else
698  {
699  bCol = false;
700  }
701  }
702 
703  if ( !bRow && !bCol )
704  {
705  return false;
706  }
707 
708  SCCOL nMarkEndCol = nEndCol;
709  SCROW nMarkEndRow = nEndRow;
710  ScAutoSum eSum = ScAutoSumNone;
711  SCROW nColSums = 0;
712  SCCOL nRowSums = 0;
713  SCROW nColSumsStartRow = 0;
714  SCCOL nRowSumsStartCol = 0;
715 
716  if ( bRow )
717  {
718  // calculate the row sums for all columns of the given range
719 
720  SCROW nSumEndRow = nEndRow;
721 
722  if ( bEndRowEmpty )
723  {
724  // the last row of the given range is empty;
725  // don't take into account for calculating the autosum
726  --nSumEndRow;
727  }
728  else
729  {
730  // increase mark range
731  ++nMarkEndRow;
732  }
733 
734  for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
735  {
736  if ( !rDoc.IsBlockEmpty( nTab, nCol, nStartRow, nCol, nSumEndRow ) )
737  {
738  ScRangeList aRangeList;
739  // Include the originally selected start row.
740  const ScRange aRange( nCol, rRange.aStart.Row(), nTab, nCol, nSumEndRow, nTab );
741  if ( (eSum = lcl_GetAutoSumForColumnRange( rDoc, aRangeList, aRange )) != ScAutoSumNone )
742  {
743  if (++nRowSums == 1)
744  nRowSumsStartCol = aRangeList[0].aStart.Col();
745  const OUString aFormula = GetAutoSumFormula(
746  aRangeList, bSubTotal, ScAddress(nCol, nInsRow, nTab), eCode);
747  EnterData( nCol, nInsRow, nTab, aFormula );
748  }
749  }
750  }
751  }
752 
753  if ( bCol )
754  {
755  // calculate the column sums for all rows of the given range
756 
757  SCCOL nSumEndCol = nEndCol;
758 
759  if ( bEndColEmpty )
760  {
761  // the last column of the given range is empty;
762  // don't take into account for calculating the autosum
763  --nSumEndCol;
764  }
765  else
766  {
767  // increase mark range
768  ++nMarkEndCol;
769  }
770 
771  for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
772  {
773  if ( !rDoc.IsBlockEmpty( nTab, nStartCol, nRow, nSumEndCol, nRow ) )
774  {
775  ScRangeList aRangeList;
776  // Include the originally selected start column.
777  const ScRange aRange( rRange.aStart.Col(), nRow, nTab, nSumEndCol, nRow, nTab );
778  if ( (eSum = lcl_GetAutoSumForRowRange( rDoc, aRangeList, aRange )) != ScAutoSumNone )
779  {
780  if (++nColSums == 1)
781  nColSumsStartRow = aRangeList[0].aStart.Row();
782  const OUString aFormula = GetAutoSumFormula( aRangeList, bSubTotal, ScAddress(nInsCol, nRow, nTab), eCode );
783  EnterData( nInsCol, nRow, nTab, aFormula );
784  }
785  }
786  }
787  }
788 
789  // Set new mark range and cursor position.
790  // For sum of sums (and data until sum) mark the actual resulting range if
791  // there is only one, or the data range if more than one. Otherwise use the
792  // original selection. All extended by end column/row where the sum is put.
793  const ScRange aMarkRange(
794  (eSum >= ScAutoSumSum ?
795  (nRowSums == 1 ? nRowSumsStartCol : nStartCol) :
796  rRange.aStart.Col()),
797  (eSum >= ScAutoSumSum ?
798  (nColSums == 1 ? nColSumsStartRow : nStartRow) :
799  rRange.aStart.Row()),
800  nTab, nMarkEndCol, nMarkEndRow, nTab );
801  MarkRange( aMarkRange, false, bContinue );
802  if ( bSetCursor )
803  {
804  SetCursor( nMarkEndCol, nMarkEndRow );
805  }
806 
807  return true;
808 }
809 
810 OUString ScViewFunc::GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr , const OpCode eCode)
811 {
812  ScViewData& rViewData = GetViewData();
813  ScDocument& rDoc = rViewData.GetDocument();
814  ScTokenArray aArray(rDoc);
815 
816  aArray.AddOpCode(bSubTotal ? ocSubTotal : eCode);
817  aArray.AddOpCode(ocOpen);
818 
819  if (bSubTotal)
820  {
821  aArray.AddDouble( GetSubTotal( eCode ) );
822  aArray.AddOpCode(ocSep);
823  }
824 
825  if(!rRangeList.empty())
826  {
827  ScRangeList aRangeList = rRangeList;
828  size_t ListSize = aRangeList.size();
829  for ( size_t i = 0; i < ListSize; ++i )
830  {
831  const ScRange & r = aRangeList[i];
832  if (i != 0)
833  aArray.AddOpCode(ocSep);
834  ScComplexRefData aRef;
835  aRef.InitRangeRel(rDoc, r, rAddr);
836  aArray.AddDoubleReference(aRef);
837  }
838  }
839 
840  aArray.AddOpCode(ocClose);
841 
842  ScCompiler aComp(rDoc, rAddr, aArray, rDoc.GetGrammar());
843  OUStringBuffer aBuf;
844  aComp.CreateStringFromTokenArray(aBuf);
845  OUString aFormula = aBuf.makeStringAndClear();
846  aBuf.append('=');
847  aBuf.append(aFormula);
848  return aBuf.makeStringAndClear();
849 }
850 
851 void ScViewFunc::EnterBlock( const OUString& rString, const EditTextObject* pData )
852 {
853  // test for multi selection
854 
855  SCCOL nCol = GetViewData().GetCurX();
856  SCROW nRow = GetViewData().GetCurY();
857  SCTAB nTab = GetViewData().GetTabNo();
858  ScMarkData& rMark = GetViewData().GetMarkData();
859  if ( rMark.IsMultiMarked() )
860  {
861  rMark.MarkToSimple();
862  if ( rMark.IsMultiMarked() )
863  { // "Insert into multi selection not possible"
864  ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
865 
866  // insert into single cell
867  if ( pData )
868  EnterData(nCol, nRow, nTab, *pData);
869  else
870  EnterData( nCol, nRow, nTab, rString );
871  return;
872  }
873  }
874 
875  if (GetViewData().SelectionForbidsCellFill())
876  {
877  PaintArea(nCol, nRow, nCol, nRow); // possibly the edit-engine is still painted there
878  return;
879  }
880 
881  ScDocument& rDoc = GetViewData().GetDocument();
882  OUString aNewStr = rString;
883  if ( pData )
884  {
885  const ScPatternAttr* pOldPattern = rDoc.GetPattern( nCol, nRow, nTab );
886  ScTabEditEngine aEngine( *pOldPattern, rDoc.GetEnginePool(), &rDoc );
887  aEngine.SetTextCurrentDefaults(*pData);
888 
889  ScEditAttrTester aTester( &aEngine );
890  if (!aTester.NeedsObject())
891  {
892  aNewStr = aEngine.GetText();
893  pData = nullptr;
894  }
895  }
896 
897  // Insert via PasteFromClip
898  weld::WaitObject aWait(GetViewData().GetDialogParent());
899 
900  ScAddress aPos( nCol, nRow, nTab );
901 
903  pInsDoc->ResetClip( &rDoc, nTab );
904 
905  if (aNewStr[0] == '=') // Formula ?
906  {
907  // SetString not possible, because in Clipboard-Documents nothing will be compiled!
908  pInsDoc->SetFormulaCell(aPos, new ScFormulaCell(rDoc, aPos, aNewStr));
909  }
910  else if ( pData )
911  {
912  // A copy of pData will be stored.
913  pInsDoc->SetEditText(aPos, *pData, rDoc.GetEditPool());
914  }
915  else
916  pInsDoc->SetString( nCol, nRow, nTab, aNewStr );
917 
918  pInsDoc->SetClipArea( ScRange(aPos) );
919  // insert Block, with Undo etc.
920  if ( !PasteFromClip( InsertDeleteFlags::CONTENTS, pInsDoc.get(), ScPasteFunc::NONE, false, false,
922  return;
923 
924  const SfxUInt32Item* pItem = pInsDoc->GetAttr(
925  nCol, nRow, nTab, ATTR_VALUE_FORMAT );
926  if ( pItem )
927  { // set number format if incompatible
928  // MarkData was already MarkToSimple'ed in PasteFromClip
929  ScRange aRange;
930  rMark.GetMarkArea( aRange );
931  ScPatternAttr aPattern( rDoc.GetPool() );
932  aPattern.GetItemSet().Put( *pItem );
933  SvNumFormatType nNewType = rDoc.GetFormatTable()->GetType( pItem->GetValue() );
934  rDoc.ApplyPatternIfNumberformatIncompatible( aRange, rMark,
935  aPattern, nNewType );
936  }
937 }
938 
939 // manual page break
940 
941 void ScViewFunc::InsertPageBreak( bool bColumn, bool bRecord, const ScAddress* pPos,
942  bool bSetModified )
943 {
944  SCTAB nTab = GetViewData().GetTabNo();
945  ScAddress aCursor;
946  if (pPos)
947  aCursor = *pPos;
948  else
949  aCursor = ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), nTab );
950 
951  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
952  InsertPageBreak( bColumn, aCursor, bRecord, bSetModified );
953 
954  if ( bSuccess && bSetModified )
955  UpdatePageBreakData( true ); // for PageBreak-Mode
956 }
957 
958 void ScViewFunc::DeletePageBreak( bool bColumn, bool bRecord, const ScAddress* pPos,
959  bool bSetModified )
960 {
961  SCTAB nTab = GetViewData().GetTabNo();
962  ScAddress aCursor;
963  if (pPos)
964  aCursor = *pPos;
965  else
966  aCursor = ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), nTab );
967 
968  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
969  RemovePageBreak( bColumn, aCursor, bRecord, bSetModified );
970 
971  if ( bSuccess && bSetModified )
972  UpdatePageBreakData( true ); // for PageBreak-Mode
973 }
974 
976 {
977  ScDocShell* pDocSh = GetViewData().GetDocShell();
978  ScDocument& rDoc = pDocSh->GetDocument();
979  SCTAB nTab = GetViewData().GetTabNo();
980  bool bUndo(rDoc.IsUndoEnabled());
981 
982  if (bUndo)
983  {
985  pUndoDoc->InitUndo( rDoc, nTab, nTab, true, true );
986  rDoc.CopyToDocument( 0,0,nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab, InsertDeleteFlags::NONE, false, *pUndoDoc );
987  pDocSh->GetUndoManager()->AddUndoAction(
988  std::make_unique<ScUndoRemoveBreaks>( pDocSh, nTab, std::move(pUndoDoc) ) );
989  }
990 
991  rDoc.RemoveManualBreaks(nTab);
992  rDoc.UpdatePageBreaks(nTab);
993 
994  UpdatePageBreakData( true );
995  pDocSh->SetDocumentModified();
996  pDocSh->PostPaint( 0,0,nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab, PaintPartFlags::Grid );
997 }
998 
999 void ScViewFunc::SetPrintZoom(sal_uInt16 nScale)
1000 {
1001  ScDocShell* pDocSh = GetViewData().GetDocShell();
1002  SCTAB nTab = GetViewData().GetTabNo();
1003  pDocSh->SetPrintZoom( nTab, nScale, 0/*nPages*/ );
1004 }
1005 
1007 {
1008  ScRange aRange;
1009  if ( GetViewData().GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
1010  GetViewData().GetMarkData().GetMultiMarkArea( aRange );
1011  GetViewData().GetDocShell()->AdjustPrintZoom( aRange );
1012 }
1013 
1014 void ScViewFunc::SetPrintRanges( bool bEntireSheet, const OUString* pPrint,
1015  const OUString* pRepCol, const OUString* pRepRow,
1016  bool bAddPrint )
1017 {
1018  // on all selected tables
1019 
1020  ScDocShell* pDocSh = GetViewData().GetDocShell();
1021  ScDocument& rDoc = pDocSh->GetDocument();
1022  ScMarkData& rMark = GetViewData().GetMarkData();
1023  bool bUndo (rDoc.IsUndoEnabled());
1024 
1025  std::unique_ptr<ScPrintRangeSaver> pOldRanges = rDoc.CreatePrintRangeSaver();
1026 
1027  ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
1028 
1029  for (const SCTAB& nTab : rMark)
1030  {
1031  ScRange aRange( 0,0,nTab );
1032 
1033  // print ranges
1034 
1035  if( !bAddPrint )
1036  rDoc.ClearPrintRanges( nTab );
1037 
1038  if( bEntireSheet )
1039  {
1040  rDoc.SetPrintEntireSheet( nTab );
1041  }
1042  else if ( pPrint )
1043  {
1044  if ( !pPrint->isEmpty() )
1045  {
1047  sal_Int32 nPos = 0;
1048  do
1049  {
1050  const OUString aToken = pPrint->getToken(0, sep, nPos);
1051  if ( aRange.ParseAny( aToken, rDoc, aDetails ) & ScRefFlags::VALID )
1052  rDoc.AddPrintRange( nTab, aRange );
1053  }
1054  while (nPos >= 0);
1055  }
1056  }
1057  else // NULL = use selection (print range is always set), use empty string to delete all ranges
1058  {
1059  if ( GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
1060  {
1061  rDoc.AddPrintRange( nTab, aRange );
1062  }
1063  else if ( rMark.IsMultiMarked() )
1064  {
1065  rMark.MarkToMulti();
1066  ScRangeListRef pList( new ScRangeList );
1067  rMark.FillRangeListWithMarks( pList.get(), false );
1068  for (size_t i = 0, n = pList->size(); i < n; ++i)
1069  {
1070  const ScRange & rR = (*pList)[i];
1071  rDoc.AddPrintRange(nTab, rR);
1072  }
1073  }
1074  }
1075 
1076  // repeat columns
1077 
1078  if ( pRepCol )
1079  {
1080  if ( pRepCol->isEmpty() )
1081  rDoc.SetRepeatColRange( nTab, nullptr );
1082  else
1083  if ( aRange.ParseAny( *pRepCol, rDoc, aDetails ) & ScRefFlags::VALID )
1084  rDoc.SetRepeatColRange( nTab, std::unique_ptr<ScRange>(new ScRange(aRange)) );
1085  }
1086 
1087  // repeat rows
1088 
1089  if ( pRepRow )
1090  {
1091  if ( pRepRow->isEmpty() )
1092  rDoc.SetRepeatRowRange( nTab, nullptr );
1093  else
1094  if ( aRange.ParseAny( *pRepRow, rDoc, aDetails ) & ScRefFlags::VALID )
1095  rDoc.SetRepeatRowRange( nTab, std::unique_ptr<ScRange>(new ScRange(aRange)) );
1096  }
1097  }
1098 
1099  // undo (for all tables)
1100  if (bUndo)
1101  {
1102  SCTAB nCurTab = GetViewData().GetTabNo();
1103  std::unique_ptr<ScPrintRangeSaver> pNewRanges = rDoc.CreatePrintRangeSaver();
1104  pDocSh->GetUndoManager()->AddUndoAction(
1105  std::make_unique<ScUndoPrintRange>( pDocSh, nCurTab, std::move(pOldRanges), std::move(pNewRanges) ) );
1106  }
1107  else
1108  pOldRanges.reset();
1109 
1110  // update page breaks
1111 
1112  for (const auto& rTab : rMark)
1113  ScPrintFunc( pDocSh, pDocSh->GetPrinter(), rTab ).UpdatePages();
1114 
1115  SfxBindings& rBindings = GetViewData().GetBindings();
1116  rBindings.Invalidate( SID_DELETE_PRINTAREA );
1117 
1118  pDocSh->SetDocumentModified();
1119 }
1120 
1121 // Merge cells
1122 
1123 bool ScViewFunc::TestMergeCells() // pre-test (for menu)
1124 {
1125  // simple test: true if there's a selection but no multi selection and not filtered
1126 
1127  const ScMarkData& rMark = GetViewData().GetMarkData();
1128  if ( rMark.IsMarked() || rMark.IsMultiMarked() )
1129  {
1130  ScRange aRange;
1131  bool bMergeable = ( GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE );
1132  bMergeable = bMergeable && ( aRange.aStart.Col() != aRange.aEnd.Col() ||
1133  aRange.aStart.Row() != aRange.aEnd.Row() );
1134  return bMergeable;
1135  }
1136  else
1137  return false;
1138 }
1139 
1140 bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
1141 {
1142  // Editable- and Being-Nested- test must be at the beginning (in DocFunc too),
1143  // so that the Contents-QueryBox won't appear
1144  ScEditableTester aTester( this );
1145  if (!aTester.IsEditable())
1146  {
1147  ErrorMessage(aTester.GetMessageId());
1148  return false;
1149  }
1150 
1151  ScMarkData& rMark = GetViewData().GetMarkData();
1152  rMark.MarkToSimple();
1153  if (!rMark.IsMarked())
1154  {
1155  ErrorMessage(STR_NOMULTISELECT);
1156  return false;
1157  }
1158 
1159  ScDocShell* pDocSh = GetViewData().GetDocShell();
1160  ScDocument& rDoc = pDocSh->GetDocument();
1161 
1162  ScRange aMarkRange;
1163  rMark.GetMarkArea( aMarkRange );
1164  SCCOL nStartCol = aMarkRange.aStart.Col();
1165  SCROW nStartRow = aMarkRange.aStart.Row();
1166  SCTAB nStartTab = aMarkRange.aStart.Tab();
1167  SCCOL nEndCol = aMarkRange.aEnd.Col();
1168  SCROW nEndRow = aMarkRange.aEnd.Row();
1169  SCTAB nEndTab = aMarkRange.aEnd.Tab();
1170  if ( nStartCol == nEndCol && nStartRow == nEndRow )
1171  {
1172  // nothing to do
1173  return true;
1174  }
1175 
1176  if ( rDoc.HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
1178  { // "Don't nest merging !"
1179  ErrorMessage(STR_MSSG_MERGECELLS_0);
1180  return false;
1181  }
1182 
1183  // Check for the contents of all selected tables.
1184  bool bAskDialog = false;
1185  ScCellMergeOption aMergeOption(nStartCol, nStartRow, nEndCol, nEndRow, bCenter);
1186  for (const SCTAB& i : rMark)
1187  {
1188  aMergeOption.maTabs.insert(i);
1189 
1190  sc::MultiDataCellState aState = rDoc.HasMultipleDataCells(aMergeOption.getSingleRange(i));
1191  switch (aState.meState)
1192  {
1194  {
1195  // this range contains multiple data cells.
1196  bAskDialog = true;
1197  break;
1198  }
1200  {
1201  // this range contains only one data cell.
1202  if (nStartCol != aState.mnCol1 || nStartRow != aState.mnRow1)
1203  rDoContents = true; // move the value to the top-left.
1204  break;
1205  }
1206  default:
1207  ;
1208  }
1209  }
1210 
1211  bool bOk = true;
1212  bool bEmptyMergedCells = officecfg::Office::Calc::Compatibility::MergeCells::EmptyMergedCells::get();
1213 
1214  if (bAskDialog)
1215  {
1216  bool bShowDialog = officecfg::Office::Calc::Compatibility::MergeCells::ShowDialog::get();
1217  if (!bApi && bShowDialog)
1218  {
1219  ScMergeCellsDialog aBox(GetViewData().GetDialogParent());
1220  sal_uInt16 nRetVal = aBox.run();
1221 
1222  if ( nRetVal == RET_OK )
1223  {
1224  switch (aBox.GetMergeCellsOption())
1225  {
1227  rDoContents = true;
1228  break;
1230  bEmptyMergedCells = false;
1231  break;
1233  bEmptyMergedCells = true;
1234  break;
1235  default:
1236  assert(!"Unknown option for merge cells.");
1237  break;
1238  }
1239  }
1240  else if ( nRetVal == RET_CANCEL )
1241  bOk = false;
1242  }
1243  }
1244 
1245  if (bOk)
1246  {
1247  bOk = pDocSh->GetDocFunc().MergeCells( aMergeOption, rDoContents, true/*bRecord*/, bApi, bEmptyMergedCells );
1248 
1249  if (bOk)
1250  {
1251  SetCursor( nStartCol, nStartRow );
1252  //DoneBlockMode( sal_False);
1253  Unmark();
1254 
1255  pDocSh->UpdateOle(GetViewData());
1256  UpdateInputLine();
1257 
1258  OUString aStartAddress = aMarkRange.aStart.GetColRowString();
1259  OUString aEndAddress = aMarkRange.aEnd.GetColRowString();
1260 
1261  collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "MERGE_CELLS");
1262  }
1263  }
1264 
1265  return bOk;
1266 }
1267 
1269 {
1270  bool bMerged = false;
1271  ScRange aRange;
1272  if (GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE)
1273  {
1274  ScDocument& rDoc = GetViewData().GetDocument();
1275  if ( rDoc.HasAttrib( aRange, HasAttrFlags::Merged ) )
1276  bMerged = true;
1277  }
1278  return bMerged;
1279 }
1280 
1281 static bool lcl_extendMergeRange(ScCellMergeOption& rOption, const ScRange& rRange)
1282 {
1283  bool bExtended = false;
1284  if (rOption.mnStartCol > rRange.aStart.Col())
1285  {
1286  rOption.mnStartCol = rRange.aStart.Col();
1287  bExtended = true;
1288  }
1289  if (rOption.mnStartRow > rRange.aStart.Row())
1290  {
1291  rOption.mnStartRow = rRange.aStart.Row();
1292  bExtended = true;
1293  }
1294  if (rOption.mnEndCol < rRange.aEnd.Col())
1295  {
1296  rOption.mnEndCol = rRange.aEnd.Col();
1297  bExtended = true;
1298  }
1299  if (rOption.mnEndRow < rRange.aEnd.Row())
1300  {
1301  rOption.mnEndRow = rRange.aEnd.Row();
1302  bExtended = true;
1303  }
1304  return bExtended;
1305 }
1306 
1308 {
1309  ScRange aRange;
1310  ScEditableTester aTester( this );
1311  if (!aTester.IsEditable())
1312  {
1313  ErrorMessage(aTester.GetMessageId());
1314  return false;
1315  }
1316  else if (GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE)
1317  {
1318  ScDocument& rDoc = GetViewData().GetDocument();
1319  ScRange aExtended( aRange );
1320  rDoc.ExtendMerge( aExtended );
1321  ScDocShell* pDocSh = GetViewData().GetDocShell();
1322  const ScMarkData& rMark = GetViewData().GetMarkData();
1323  ScCellMergeOption aOption(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row());
1324  bool bExtended = false;
1325  do
1326  {
1327  bExtended = false;
1328  for (const SCTAB& i : rMark)
1329  {
1330  aOption.maTabs.insert(i);
1331  aExtended.aStart.SetTab(i);
1332  aExtended.aEnd.SetTab(i);
1333  rDoc.ExtendMerge(aExtended);
1334  rDoc.ExtendOverlapped(aExtended);
1335 
1336  // Expand the current range to be inclusive of all merged
1337  // areas on all sheets.
1338  bExtended = lcl_extendMergeRange(aOption, aExtended);
1339  }
1340  }
1341  while (bExtended);
1342 
1343  bool bOk = pDocSh->GetDocFunc().UnmergeCells(aOption, true/*bRecord*/, nullptr);
1344  aExtended = aOption.getFirstSingleRange();
1345  MarkRange( aExtended );
1346 
1347  if (bOk)
1348  pDocSh->UpdateOle(GetViewData());
1349  }
1350 
1351  OUString aCellLocation = aRange.aStart.GetColRowString();
1352  collectUIInformation({{"CELL", aCellLocation}}, "UNMERGE_CELL");
1353 
1354  return true;
1355 }
1356 
1358 {
1359  ScRange aRange;
1360  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1361  {
1362  ScDocShell* pDocSh = GetViewData().GetDocShell();
1363  const ScMarkData& rMark = GetViewData().GetMarkData();
1364  bool bSuccess = pDocSh->GetDocFunc().FillSimple( aRange, &rMark, eDir, false );
1365  if (bSuccess)
1366  {
1367  pDocSh->UpdateOle(GetViewData());
1368  UpdateScrollBars();
1369 
1370  auto& rDoc = pDocSh->GetDocument();
1371  bool bDoAutoSpell = rDoc.GetDocOptions().IsAutoSpell();
1372  if ( bDoAutoSpell )
1373  {
1374  // Copy AutoSpellData from above(left/right/below) if no selection.
1375  switch (eDir)
1376  {
1377  case FILL_TO_BOTTOM:
1378  if (aRange.aStart.Row() > 0 && aRange.aStart.Row() == aRange.aEnd.Row())
1379  aRange.aStart.IncRow(-1);
1380  break;
1381  case FILL_TO_TOP:
1382  if (aRange.aEnd.Row() < rDoc.MaxRow() && aRange.aStart.Row() == aRange.aEnd.Row())
1383  aRange.aEnd.IncRow(1);
1384  break;
1385  case FILL_TO_RIGHT:
1386  if (aRange.aStart.Col() > 0 && aRange.aStart.Col() == aRange.aEnd.Col())
1387  aRange.aStart.IncCol(-1);
1388  break;
1389  case FILL_TO_LEFT:
1390  if (aRange.aEnd.Col() < rDoc.MaxCol() && aRange.aStart.Col() == aRange.aEnd.Col())
1391  aRange.aEnd.IncCol(1);
1392  break;
1393  }
1394  CopyAutoSpellData(eDir, aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(),
1395  ::std::numeric_limits<sal_uLong>::max());
1396  }
1397 
1398  // Invalidate cell slots and update input line with new content.
1399  CellContentChanged();
1400  }
1401  }
1402  else
1403  ErrorMessage(STR_NOMULTISELECT);
1404 }
1405 
1407  double fStart, double fStep, double fMax )
1408 {
1409  ScRange aRange;
1410  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1411  {
1412  ScDocShell* pDocSh = GetViewData().GetDocShell();
1413  const ScMarkData& rMark = GetViewData().GetMarkData();
1414  bool bSuccess = pDocSh->GetDocFunc().
1415  FillSeries( aRange, &rMark, eDir, eCmd, eDateCmd,
1416  fStart, fStep, fMax, false );
1417  if (bSuccess)
1418  {
1419  pDocSh->UpdateOle(GetViewData());
1420  UpdateScrollBars();
1421 
1423  }
1424  }
1425  else
1426  ErrorMessage(STR_NOMULTISELECT);
1427 }
1428 
1429 void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
1430  SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount )
1431 {
1432  SCTAB nTab = GetViewData().GetTabNo();
1433  ScRange aRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab );
1434  ScRange aSourceRange( aRange );
1435  ScDocShell* pDocSh = GetViewData().GetDocShell();
1436  const ScMarkData& rMark = GetViewData().GetMarkData();
1437  bool bSuccess = pDocSh->GetDocFunc().
1438  FillAuto( aRange, &rMark, eDir, nCount, false );
1439  if (!bSuccess)
1440  return;
1441 
1442  MarkRange( aRange, false ); // aRange was modified in FillAuto
1443  pDocSh->UpdateOle(GetViewData());
1444  UpdateScrollBars();
1445 
1446  bool bDoAutoSpell = pDocSh->GetDocument().GetDocOptions().IsAutoSpell();
1447  if ( bDoAutoSpell )
1448  CopyAutoSpellData(eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount);
1449 
1451  if (!pModelObj)
1452  return;
1453 
1454  ScRangeList aChangeRanges;
1455  ScRange aChangeRange( aRange );
1456  switch (eDir)
1457  {
1458  case FILL_TO_BOTTOM:
1459  aChangeRange.aStart.SetRow( aSourceRange.aEnd.Row() + 1 );
1460  break;
1461  case FILL_TO_TOP:
1462  aChangeRange.aEnd.SetRow( aSourceRange.aStart.Row() - 1 );
1463  break;
1464  case FILL_TO_RIGHT:
1465  aChangeRange.aStart.SetCol( aSourceRange.aEnd.Col() + 1 );
1466  break;
1467  case FILL_TO_LEFT:
1468  aChangeRange.aEnd.SetCol( aSourceRange.aStart.Col() - 1 );
1469  break;
1470  default:
1471  break;
1472  }
1473  aChangeRanges.push_back( aChangeRange );
1474  HelperNotifyChanges::Notify(*pModelObj, aChangeRanges);
1475 }
1476 
1477 void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
1478  SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount )
1479 {
1480  const ScDocument* pDoc = &GetViewData().GetDocument();
1481  SCTAB nTab = GetViewData().GetTabNo();
1482  CellType eCellType;
1483 
1484  ScGridWindow* pWin = GetActiveWin();
1485  if ( pWin->InsideVisibleRange(nStartCol, nStartRow) && pWin->InsideVisibleRange(nEndCol, nEndRow) )
1486  {
1487  if ( nCount == ::std::numeric_limits<sal_uLong>::max() )
1488  {
1489  switch( eDir )
1490  {
1491  case FILL_TO_BOTTOM:
1492  for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
1493  {
1494  pDoc->GetCellType(nColItr, nStartRow, nTab, eCellType); // We need this optimization only for EditTextObject source cells
1495  if (eCellType != CELLTYPE_EDIT)
1496  continue;
1497 
1498  const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nColItr, nStartRow);
1499  if ( !pRanges )
1500  continue;
1501  for ( SCROW nRowItr = nStartRow + 1; nRowItr <= nEndRow; ++nRowItr )
1502  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1503  }
1504  break;
1505  case FILL_TO_TOP:
1506  for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
1507  {
1508  pDoc->GetCellType(nColItr, nEndRow, nTab, eCellType); // We need this optimization only for EditTextObject source cells
1509  if (eCellType != CELLTYPE_EDIT)
1510  continue;
1511 
1512  const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nColItr, nEndRow);
1513  if ( !pRanges )
1514  continue;
1515  for ( SCROW nRowItr = nEndRow - 1; nRowItr >= nStartRow; --nRowItr )
1516  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1517  }
1518  break;
1519  case FILL_TO_RIGHT:
1520  for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
1521  {
1522  pDoc->GetCellType(nStartCol, nRowItr, nTab, eCellType); // We need this optimization only for EditTextObject source cells
1523  if (eCellType != CELLTYPE_EDIT)
1524  continue;
1525 
1526  const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nStartCol, nRowItr);
1527  if ( !pRanges )
1528  continue;
1529  for ( SCCOL nColItr = nStartCol + 1; nColItr <= nEndCol; ++nColItr )
1530  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1531  }
1532  break;
1533  case FILL_TO_LEFT:
1534  for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
1535  {
1536  pDoc->GetCellType(nEndCol, nRowItr, nTab, eCellType); // We need this optimization only for EditTextObject source cells
1537  if (eCellType != CELLTYPE_EDIT)
1538  continue;
1539 
1540  const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nEndCol, nRowItr);
1541  if ( !pRanges )
1542  continue;
1543  for ( SCCOL nColItr = nEndCol - 1; nColItr >= nStartCol; --nColItr )
1544  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1545  }
1546  break;
1547  }
1548  return;
1549  }
1550 
1551  typedef const std::vector<editeng::MisspellRanges>* MisspellRangesType;
1552  SCROW nRowRepeatSize = nEndRow - nStartRow + 1;
1553  SCCOL nColRepeatSize = nEndCol - nStartCol + 1;
1554  SCROW nTillRow = 0;
1555  SCCOL nTillCol = 0;
1556  std::vector<std::vector<MisspellRangesType>> aSourceSpellRanges(nRowRepeatSize, std::vector<MisspellRangesType>(nColRepeatSize, nullptr));
1557 
1558  for ( SCROW nRowIdx = 0; nRowIdx < nRowRepeatSize; ++nRowIdx )
1559  {
1560  for ( SCCOL nColIdx = 0; nColIdx < nColRepeatSize; ++nColIdx )
1561  {
1562  pDoc->GetCellType(nStartCol + nColIdx, nStartRow + nRowIdx, nTab, eCellType); // We need this optimization only for EditTextObject source cells
1563  if (eCellType != CELLTYPE_EDIT)
1564  continue;
1565 
1566  aSourceSpellRanges[nRowIdx][nColIdx] = pWin->GetAutoSpellData( nStartCol + nColIdx, nStartRow + nRowIdx );
1567  }
1568  }
1569 
1570  switch( eDir )
1571  {
1572  case FILL_TO_BOTTOM:
1573  nTillRow = nEndRow + nCount;
1574  for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
1575  {
1576  for ( SCROW nRowItr = nEndRow + 1; nRowItr <= nTillRow; ++nRowItr )
1577  {
1578  size_t nSourceRowIdx = ( nRowItr - nEndRow - 1 ) % nRowRepeatSize;
1579  MisspellRangesType pRanges = aSourceSpellRanges[nSourceRowIdx][nColItr - nStartCol];
1580  if ( !pRanges )
1581  continue;
1582  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1583  }
1584  }
1585  break;
1586 
1587  case FILL_TO_TOP:
1588  nTillRow = nStartRow - nCount;
1589  for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
1590  {
1591  for ( SCROW nRowItr = nStartRow - 1; nRowItr >= nTillRow; --nRowItr )
1592  {
1593  size_t nSourceRowIdx = nRowRepeatSize - 1 - ( ( nStartRow - 1 - nRowItr ) % nRowRepeatSize );
1594  MisspellRangesType pRanges = aSourceSpellRanges[nSourceRowIdx][nColItr - nStartCol];
1595  if ( !pRanges )
1596  continue;
1597  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1598  }
1599  }
1600  break;
1601 
1602  case FILL_TO_RIGHT:
1603  nTillCol = nEndCol + nCount;
1604  for ( SCCOL nColItr = nEndCol + 1; nColItr <= nTillCol; ++nColItr )
1605  {
1606  size_t nSourceColIdx = ( nColItr - nEndCol - 1 ) % nColRepeatSize;
1607  for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
1608  {
1609  MisspellRangesType pRanges = aSourceSpellRanges[nRowItr - nStartRow][nSourceColIdx];
1610  if ( !pRanges )
1611  continue;
1612  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1613  }
1614  }
1615  break;
1616 
1617  case FILL_TO_LEFT:
1618  nTillCol = nStartCol - nCount;
1619  for ( SCCOL nColItr = nStartCol - 1; nColItr >= nTillCol; --nColItr )
1620  {
1621  size_t nSourceColIdx = nColRepeatSize - 1 - ( ( nStartCol - 1 - nColItr ) % nColRepeatSize );
1622  for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
1623  {
1624  MisspellRangesType pRanges = aSourceSpellRanges[nRowItr - nStartRow][nSourceColIdx];
1625  if ( !pRanges )
1626  continue;
1627  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1628  }
1629  }
1630  break;
1631  }
1632  }
1633  else
1635 
1636 }
1637 
1638 void ScViewFunc::FillTab( InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink )
1639 {
1641  ScEditableTester aTester( this );
1642  if (!aTester.IsEditable())
1643  {
1644  ErrorMessage(aTester.GetMessageId());
1645  return;
1646  }
1647 
1648  ScDocShell* pDocSh = GetViewData().GetDocShell();
1649  ScDocument& rDoc = pDocSh->GetDocument();
1650  ScMarkData& rMark = GetViewData().GetMarkData();
1651  SCTAB nTab = GetViewData().GetTabNo();
1652  bool bUndo(rDoc.IsUndoEnabled());
1653 
1654  ScRange aMarkRange;
1655  rMark.MarkToSimple();
1656  bool bMulti = rMark.IsMultiMarked();
1657  if (bMulti)
1658  rMark.GetMultiMarkArea( aMarkRange );
1659  else if (rMark.IsMarked())
1660  rMark.GetMarkArea( aMarkRange );
1661  else
1662  aMarkRange = ScRange( GetViewData().GetCurX(), GetViewData().GetCurY(), nTab );
1663 
1664  ScDocumentUniquePtr pUndoDoc;
1665 
1666  if (bUndo)
1667  {
1668  pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
1669  pUndoDoc->InitUndo( rDoc, nTab, nTab );
1670 
1671  for (const SCTAB& i : rMark)
1672  if (i != nTab )
1673  {
1674  pUndoDoc->AddUndoTab( i, i );
1675  aMarkRange.aStart.SetTab( i );
1676  aMarkRange.aEnd.SetTab( i );
1677  rDoc.CopyToDocument( aMarkRange, InsertDeleteFlags::ALL, bMulti, *pUndoDoc );
1678  }
1679  }
1680 
1681  if (bMulti)
1682  rDoc.FillTabMarked( nTab, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
1683  else
1684  {
1685  aMarkRange.aStart.SetTab( nTab );
1686  aMarkRange.aEnd.SetTab( nTab );
1687  rDoc.FillTab( aMarkRange, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
1688  }
1689 
1690  if (bUndo)
1691  {
1692  pDocSh->GetUndoManager()->AddUndoAction(
1693  std::make_unique<ScUndoFillTable>( pDocSh, rMark,
1694  aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nTab,
1695  aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), nTab,
1696  std::move(pUndoDoc), bMulti, nTab, nFlags, nFunction, bSkipEmpty, bAsLink ) );
1697  }
1698 
1699  pDocSh->PostPaintGridAll();
1700  pDocSh->PostDataChanged();
1701 }
1702 
1719 {
1720  ScRange aRange;
1721  GetViewData().GetSimpleArea( aRange );
1722  aRange.PutInOrder();
1723 
1724  SCTAB nTab = GetViewData().GetCurPos().Tab();
1725  SCCOL nStartX = aRange.aStart.Col();
1726  SCROW nStartY = aRange.aStart.Row();
1727  SCCOL nEndX = aRange.aEnd.Col();
1728  SCROW nEndY = aRange.aEnd.Row();
1729 
1730  ScDocument& rDoc = GetViewData().GetDocument();
1731 
1732  if (nEndY >= rDoc.MaxRow())
1733  // Nothing to fill.
1734  return;
1735 
1736  // Make sure the selection is not empty
1737  if ( rDoc.IsBlockEmpty( nTab, nStartX, nStartY, nEndX, nEndY ) )
1738  return;
1739 
1740  // If there is data in all columns immediately below the selection then
1741  // switch to overwriting fill.
1742  SCROW nOverWriteEndRow = rDoc.MaxRow();
1743  for (SCCOL nCol = nStartX; nCol <= nEndX; ++nCol)
1744  {
1745  if (rDoc.HasData( nCol, nEndY + 1, nTab))
1746  {
1747  // Determine the shortest data column to end the fill.
1748  SCROW nY = nEndY + 1;
1749  // FindAreaPos() returns the start row of the next data block if
1750  // the current row is the last row of a data block and an empty
1751  // cell follows. Somewhat unexpected behaviour...
1752  // So check beforehand if there is one non-empty cell following.
1753  if (rDoc.HasData( nCol, nY + 1, nTab))
1754  {
1755  rDoc.FindAreaPos( nCol, nY, nTab, SC_MOVE_DOWN);
1756  if (nOverWriteEndRow > nY)
1757  nOverWriteEndRow = nY;
1758  }
1759  else
1760  {
1761  nOverWriteEndRow = nY;
1762  }
1763  }
1764  else
1765  {
1766  nOverWriteEndRow = 0;
1767  break; // for
1768  }
1769  }
1770 
1771  if (nOverWriteEndRow > nEndY)
1772  {
1773  FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY, nOverWriteEndRow - nEndY);
1774  return;
1775  }
1776 
1777  // Non-overwriting fill follows.
1778 
1779  const bool bDataLeft = (nStartX > 0);
1780  if (!bDataLeft && nEndX >= rDoc.MaxCol())
1781  // Absolutely no data left or right of selection.
1782  return;
1783 
1784  // Check that there is
1785  // 1) data immediately left (preferred) or right of start (row) of selection
1786  // 2) data there below
1787  // 3) no data immediately below selection
1788 
1789  SCCOL nMovX = (bDataLeft ? nStartX - 1 : nEndX + 1);
1790  SCROW nMovY = nStartY;
1791  bool bDataFound = (rDoc.HasData( nMovX, nStartY, nTab) && rDoc.HasData( nMovX, nStartY + 1, nTab));
1792  if (!bDataFound && bDataLeft && nEndX < rDoc.MaxCol())
1793  {
1794  nMovX = nEndX + 1; // check right
1795  bDataFound = (rDoc.HasData( nMovX, nStartY, nTab) && rDoc.HasData( nMovX, nStartY + 1, nTab));
1796  }
1797 
1798  if (!(bDataFound && rDoc.IsBlockEmpty( nTab, nStartX, nEndY + 1, nEndX, nEndY + 1, true)))
1799  return;
1800 
1801  // Get end of data left or right.
1802  rDoc.FindAreaPos( nMovX, nMovY, nTab, SC_MOVE_DOWN);
1803  // Find minimum end row of below empty area and data right.
1804  for (SCCOL nX = nStartX; nX <= nEndX; ++nX)
1805  {
1806  SCROW nY = nEndY + 1;
1807  // Get next row with data in this column.
1808  rDoc.FindAreaPos( nX, nY, nTab, SC_MOVE_DOWN);
1809  if (nMovY == rDoc.MaxRow() && nY == rDoc.MaxRow())
1810  {
1811  // FindAreaPos() returns MAXROW also if there is no data at all
1812  // from the start, so check if that contains data if the nearby
1813  // (left or right) data ends there and increment if no data
1814  // here, pretending the next data would be thereafter so nMovY
1815  // will not be decremented.
1816  if (!rDoc.HasData( nX, nY, nTab))
1817  ++nY;
1818  }
1819  if (nMovY > nY - 1)
1820  nMovY = nY - 1;
1821  }
1822 
1823  if (nMovY > nEndY)
1824  {
1825  FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY, nMovY - nEndY);
1826  }
1827 }
1828 
1830 {
1831  ScRange aRange;
1832  GetViewData().GetSimpleArea(aRange);
1833  aRange.PutInOrder();
1834 
1835  ScDocShell* pDocSh = GetViewData().GetDocShell();
1836  pDocSh->GetDocFunc().ConvertFormulaToValue(aRange, true);
1837  pDocSh->PostPaint(aRange, PaintPartFlags::Grid);
1838 }
1839 
1841 {
1842  ScMarkData aFuncMark = GetViewData().GetMarkData();
1843  if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
1844  {
1845  // no selection -> use cursor position
1846 
1847  ScAddress aCursor( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() );
1848  aFuncMark.SetMarkArea( ScRange( aCursor ) );
1849  }
1850 
1851  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
1852  TransliterateText( aFuncMark, nType, false );
1853  if (bSuccess)
1854  {
1855  GetViewData().GetViewShell()->UpdateInputHandler();
1856  }
1857 }
1858 
1859 // AutoFormat
1860 
1862 {
1863  ScAutoFormatData* pData = nullptr;
1864  SCCOL nStartCol;
1865  SCROW nStartRow;
1866  SCTAB nStartTab;
1867  SCCOL nEndCol;
1868  SCROW nEndRow;
1869  SCTAB nEndTab;
1870  if (GetViewData().GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
1871  {
1872  if ( nEndCol-nStartCol >= 3 && nEndRow-nStartRow >= 3 )
1873  {
1874  ScDocument& rDoc = GetViewData().GetDocument();
1875  pData = new ScAutoFormatData;
1876  rDoc.GetAutoFormatData( nStartTab, nStartCol,nStartRow,nEndCol,nEndRow, *pData );
1877  }
1878  }
1879  return pData;
1880 }
1881 
1882 void ScViewFunc::AutoFormat( sal_uInt16 nFormatNo )
1883 {
1884  ScRange aRange;
1885  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1886  {
1887  ScDocShell* pDocSh = GetViewData().GetDocShell();
1888  ScMarkData& rMark = GetViewData().GetMarkData();
1889 
1890  bool bSuccess = pDocSh->GetDocFunc().AutoFormat( aRange, &rMark, nFormatNo, false );
1891  if (bSuccess)
1892  pDocSh->UpdateOle(GetViewData());
1893  }
1894  else
1895  ErrorMessage(STR_NOMULTISELECT);
1896 }
1897 
1898 // Search & Replace
1899 
1901  bool bAddUndo, bool bIsApi )
1902 {
1903  SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Empty);
1904  ScDocShell* pDocSh = GetViewData().GetDocShell();
1905  ScDocument& rDoc = pDocSh->GetDocument();
1906  ScMarkData& rMark = GetViewData().GetMarkData();
1907  if (bAddUndo && !rDoc.IsUndoEnabled())
1908  bAddUndo = false;
1909 
1910  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() && (pSearchItem->HasStartPoint()) )
1911  {
1912  // No selection -> but we have a start point (top left corner of the
1913  // current view), start searching from there, not from the current
1914  // cursor position.
1915  SCCOL nPosX;
1916  SCROW nPosY;
1917 
1918  int nPixelX = pSearchItem->GetStartPointX() * GetViewData().GetPPTX();
1919  int nPixelY = pSearchItem->GetStartPointY() * GetViewData().GetPPTY();
1920 
1921  GetViewData().GetPosFromPixel(nPixelX, nPixelY, GetViewData().GetActivePart(), nPosX, nPosY);
1922 
1923  AlignToCursor( nPosX, nPosY, SC_FOLLOW_JUMP );
1924  SetCursor( nPosX, nPosY, true );
1925  }
1926 
1927  SCCOL nCol, nOldCol;
1928  SCROW nRow, nOldRow;
1929  SCTAB nTab, nOldTab;
1930  nCol = nOldCol = GetViewData().GetCurX();
1931  nRow = nOldRow = GetViewData().GetCurY();
1932  nTab = nOldTab = GetViewData().GetTabNo();
1933 
1934  SvxSearchCmd nCommand = pSearchItem->GetCommand();
1935  bool bAllTables = pSearchItem->IsAllTables();
1936  std::set<SCTAB> aOldSelectedTables;
1937  SCTAB nLastTab = rDoc.GetTableCount() - 1;
1938  SCTAB nStartTab, nEndTab;
1939  if ( bAllTables )
1940  {
1941  nStartTab = 0;
1942  nEndTab = nLastTab;
1943  std::set<SCTAB> aTmp(rMark.begin(), rMark.end());
1944  aOldSelectedTables.swap(aTmp);
1945  }
1946  else
1947  {
1948  nStartTab = rMark.GetFirstSelected();
1949  nEndTab = rMark.GetLastSelected();
1950  }
1951 
1952  if ( nCommand == SvxSearchCmd::FIND
1953  || nCommand == SvxSearchCmd::FIND_ALL)
1954  bAddUndo = false;
1955 
1957 
1958  ScDocumentUniquePtr pUndoDoc;
1959  std::unique_ptr<ScMarkData> pUndoMark;
1960  OUString aUndoStr;
1961  if (bAddUndo)
1962  {
1963  pUndoMark.reset(new ScMarkData(rMark)); // Mark is being modified
1964  if ( nCommand == SvxSearchCmd::REPLACE_ALL )
1965  {
1966  pUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
1967  pUndoDoc->InitUndo( rDoc, nStartTab, nEndTab );
1968  }
1969  }
1970 
1971  if ( bAllTables )
1972  {
1973  for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
1974  {
1975  rMark.SelectTable( j, true );
1976  }
1977  }
1978 
1979  DoneBlockMode(true); // don't delete mark
1980  InitOwnBlockMode();
1981 
1982  // If search starts at the beginning don't ask again whether it shall start at the beginning
1983  bool bFirst = true;
1984  if ( nCol == 0 && nRow == 0 && nTab == nStartTab && !pSearchItem->GetBackward() )
1985  bFirst = false;
1986 
1987  bool bFound = false;
1988  while (true)
1989  {
1990  GetFrameWin()->EnterWait();
1991  ScRangeList aMatchedRanges;
1992  if (rDoc.SearchAndReplace(*pSearchItem, nCol, nRow, nTab, rMark, aMatchedRanges, aUndoStr, pUndoDoc.get()))
1993  {
1994  bFound = true;
1995  if (bAddUndo)
1996  {
1997  GetViewData().GetDocShell()->GetUndoManager()->AddUndoAction(
1998  std::make_unique<ScUndoReplace>( GetViewData().GetDocShell(), *pUndoMark,
1999  nCol, nRow, nTab,
2000  aUndoStr, std::move(pUndoDoc), pSearchItem ) );
2001  }
2002 
2003  if (nCommand == SvxSearchCmd::FIND_ALL || nCommand == SvxSearchCmd::REPLACE_ALL)
2004  {
2005  SfxViewFrame* pViewFrm = SfxViewFrame::Current();
2006  bool bShow = GetViewData().GetViewShell()->GetViewData().GetOptions().GetOption( VOPT_SUMMARY );
2007 
2008  if (bShow && pViewFrm && !comphelper::LibreOfficeKit::isActive())
2009  {
2010  pViewFrm->ShowChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId());
2011  SfxChildWindow* pWnd = pViewFrm->GetChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId());
2012  if (pWnd)
2013  {
2014  sc::SearchResultsDlg* pDlg = static_cast<sc::SearchResultsDlg*>(pWnd->GetController().get());
2015  if (pDlg)
2016  {
2017  const bool bCellNotes = (pSearchItem->GetCellType() == SvxSearchCellType::NOTE);
2018  // ScCellIterator iterates over cells with content,
2019  // for empty cells iterate over match positions.
2020  const bool bEmptyCells = (!bCellNotes
2021  && ((nCommand == SvxSearchCmd::FIND_ALL
2022  && ScDocument::IsEmptyCellSearch(*pSearchItem))
2023  || (nCommand == SvxSearchCmd::REPLACE_ALL
2024  && pSearchItem->GetReplaceString().isEmpty())));
2025  pDlg->FillResults(rDoc, aMatchedRanges, bCellNotes, bEmptyCells);
2026  }
2027  }
2028  }
2029 
2030  rMark.ResetMark();
2031  for (size_t i = 0, n = aMatchedRanges.size(); i < n; ++i)
2032  {
2033  const ScRange& r = aMatchedRanges[i];
2034  if (r.aStart.Tab() == nTab)
2035  rMark.SetMultiMarkArea(r);
2036  }
2037  }
2038 
2039  break; // break 'while (TRUE)'
2040  }
2041  else if ( bFirst && (nCommand == SvxSearchCmd::FIND ||
2042  nCommand == SvxSearchCmd::REPLACE) )
2043  {
2044  bFirst = false;
2045  GetFrameWin()->LeaveWait();
2046  if (!bIsApi)
2047  {
2048  if ( nStartTab == nEndTab )
2049  SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::EndSheet);
2050  else
2051  SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::End);
2052 
2053  rDoc.GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
2054  if (pSearchItem->GetBackward())
2055  nTab = nEndTab;
2056  else
2057  nTab = nStartTab;
2058  }
2059  else
2060  {
2061  break; // break 'while (TRUE)'
2062  }
2063  }
2064  else // nothing found
2065  {
2066  if ( nCommand == SvxSearchCmd::FIND_ALL || nCommand == SvxSearchCmd::REPLACE_ALL )
2067  {
2068  pDocSh->PostPaintGridAll(); // Mark
2069  }
2070 
2071  GetFrameWin()->LeaveWait();
2072  if (!bIsApi)
2073  {
2074  GetViewData().GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, pSearchItem->GetSearchString().toUtf8().getStr());
2075  SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NotFound);
2076  }
2077 
2078  break; // break 'while (TRUE)'
2079  }
2080  } // of while true
2081 
2082  if (!aOldSelectedTables.empty())
2083  {
2084  // restore originally selected table
2085  for (SCTAB i = 0; i <= nEndTab; ++i)
2086  rMark.SelectTable(i, false);
2087 
2088  for (const auto& rTab : aOldSelectedTables)
2089  rMark.SelectTable(rTab, true);
2090 
2091  if ( bFound )
2092  { // if a table is selected as a "match" it remains selected.
2093  rMark.SelectTable( nTab, true );
2094  // It's a swap if only one table was selected before
2096  if ( aOldSelectedTables.size() == 1 && nTab != nOldTab )
2097  rMark.SelectTable( nOldTab, false );
2098  }
2099  }
2100 
2101  // Avoid LOK selection notifications before we have all the results.
2102  GetViewData().GetViewShell()->setTiledSearching(true);
2103  MarkDataChanged();
2104  GetViewData().GetViewShell()->setTiledSearching(false);
2105 
2106  if ( bFound )
2107  {
2108  if ( nTab != GetViewData().GetTabNo() )
2109  SetTabNo( nTab );
2110 
2111  // if nothing is marked, DoneBlockMode, then marking can start
2112  // directly from this place via Shift-Cursor
2113  if (!rMark.IsMarked() && !rMark.IsMultiMarked())
2114  DoneBlockMode(true);
2115 
2116  AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
2117  SetCursor( nCol, nRow, true );
2118 
2120  {
2121  Point aCurPos = GetViewData().GetScrPos(nCol, nRow, GetViewData().GetActivePart());
2122 
2123  // just update the cell selection
2124  ScGridWindow* pGridWindow = GetViewData().GetActiveWin();
2125  // Don't move cell selection handles for find-all: selection of all but the first result would be lost.
2126  if (pGridWindow && nCommand == SvxSearchCmd::FIND)
2127  {
2128  // move the cell selection handles
2129  pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_RESET, aCurPos.X(), aCurPos.Y());
2130  pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_START, aCurPos.X(), aCurPos.Y());
2131  pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_END, aCurPos.X(), aCurPos.Y());
2132  }
2133 
2134  if (pGridWindow)
2135  {
2136  std::vector<tools::Rectangle> aLogicRects;
2137  pGridWindow->GetCellSelection(aLogicRects);
2138 
2139  boost::property_tree::ptree aTree;
2140  aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr());
2141  aTree.put("highlightAll", nCommand == SvxSearchCmd::FIND_ALL);
2142 
2143  boost::property_tree::ptree aSelections;
2144  for (const tools::Rectangle& rLogicRect : aLogicRects)
2145  {
2146  boost::property_tree::ptree aSelection;
2147  aSelection.put("part", OString::number(nTab).getStr());
2148  aSelection.put("rectangles", rLogicRect.toString().getStr());
2149  aSelections.push_back(std::make_pair("", aSelection));
2150  }
2151  aTree.add_child("searchResultSelection", aSelections);
2152 
2153  std::stringstream aStream;
2154  boost::property_tree::write_json(aStream, aTree);
2155  OString aPayload = aStream.str().c_str();
2156  SfxViewShell* pViewShell = GetViewData().GetViewShell();
2157  pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
2158 
2159  // Trigger LOK_CALLBACK_TEXT_SELECTION now.
2160  MarkDataChanged();
2161  }
2162  }
2163 
2164  if ( nCommand == SvxSearchCmd::REPLACE
2165  || nCommand == SvxSearchCmd::REPLACE_ALL )
2166  {
2167  if ( nCommand == SvxSearchCmd::REPLACE )
2168  {
2169  pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PaintPartFlags::Grid );
2170 
2171  // jump to next cell if we replaced everything in the cell
2172  // where the cursor was positioned (but avoid switching tabs)
2173  if ( nCol == nOldCol && nRow == nOldRow && nTab == nOldTab )
2174  {
2175  SvxSearchItem aSearchItem = ScGlobal::GetSearchItem();
2176  aSearchItem.SetCommand(SvxSearchCmd::FIND);
2177  aSearchItem.SetWhich(SID_SEARCH_ITEM);
2178 
2179  ScRangeList aMatchedRanges;
2180  ScTable::UpdateSearchItemAddressForReplace( aSearchItem, nCol, nRow );
2181  if ( rDoc.SearchAndReplace( aSearchItem, nCol, nRow, nTab, rMark, aMatchedRanges, aUndoStr ) &&
2182  ( nTab == nOldTab ) &&
2183  ( nCol != nOldCol || nRow != nOldRow ) )
2184  {
2185  AlignToCursor(nCol, nRow, SC_FOLLOW_JUMP);
2186  SetCursor( nCol, nRow, true );
2187  }
2188  }
2189  }
2190  else
2191  pDocSh->PostPaintGridAll();
2192  pDocSh->SetDocumentModified();
2193  }
2194  else if ( nCommand == SvxSearchCmd::FIND_ALL )
2195  pDocSh->PostPaintGridAll(); // mark
2196  GetFrameWin()->LeaveWait();
2197  }
2198  return bFound;
2199 }
2200 
2201 // Goal Seek
2202 
2203 void ScViewFunc::Solve( const ScSolveParam& rParam )
2204 {
2205  ScDocument& rDoc = GetViewData().GetDocument();
2206 
2207  SCCOL nDestCol = rParam.aRefVariableCell.Col();
2208  SCROW nDestRow = rParam.aRefVariableCell.Row();
2209  SCTAB nDestTab = rParam.aRefVariableCell.Tab();
2210 
2211  ScEditableTester aTester( rDoc, nDestTab, nDestCol,nDestRow, nDestCol,nDestRow );
2212  if (!aTester.IsEditable())
2213  {
2214  ErrorMessage(aTester.GetMessageId());
2215  return;
2216  }
2217 
2218  OUString aTargetValStr;
2219  if ( rParam.pStrTargetVal )
2220  aTargetValStr = *rParam.pStrTargetVal;
2221 
2222  OUString aMsgStr;
2223  OUString aResStr;
2224  double nSolveResult;
2225 
2226  GetFrameWin()->EnterWait();
2227 
2228  bool bExact =
2229  rDoc.Solver(
2230  rParam.aRefFormulaCell.Col(),
2231  rParam.aRefFormulaCell.Row(),
2232  rParam.aRefFormulaCell.Tab(),
2233  nDestCol, nDestRow, nDestTab,
2234  aTargetValStr,
2235  nSolveResult );
2236 
2237  GetFrameWin()->LeaveWait();
2238 
2239  SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
2240  sal_uLong nFormat = 0;
2241  const ScPatternAttr* pPattern = rDoc.GetPattern( nDestCol, nDestRow, nDestTab );
2242  if ( pPattern )
2243  nFormat = pPattern->GetNumberFormat( pFormatter );
2244  const Color* p;
2245  pFormatter->GetOutputString( nSolveResult, nFormat, aResStr, &p );
2246 
2247  if ( bExact )
2248  {
2249  aMsgStr += ScResId( STR_MSSG_SOLVE_0 ) +
2250  aResStr +
2251  ScResId( STR_MSSG_SOLVE_1 );
2252  }
2253  else
2254  {
2255  aMsgStr = ScResId( STR_MSSG_SOLVE_2 ) +
2256  ScResId( STR_MSSG_SOLVE_3 ) +
2257  aResStr +
2258  ScResId( STR_MSSG_SOLVE_4 );
2259  }
2260 
2261  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetViewData().GetDialogParent(),
2262  VclMessageType::Question, VclButtonsType::YesNo, aMsgStr));
2263  xBox->set_title(ScResId(STR_MSSG_DOSUBTOTALS_0));
2264  xBox->set_default_response(RET_NO);
2265  if (xBox->run() == RET_YES)
2266  EnterValue( nDestCol, nDestRow, nDestTab, nSolveResult );
2267 
2268  GetViewData().GetViewShell()->UpdateInputHandler( true );
2269 }
2270 
2271 // multi operation
2272 
2273 void ScViewFunc::TabOp( const ScTabOpParam& rParam, bool bRecord )
2274 {
2275  ScRange aRange;
2276  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
2277  {
2278  ScDocShell* pDocSh = GetViewData().GetDocShell();
2279  ScMarkData& rMark = GetViewData().GetMarkData();
2280  pDocSh->GetDocFunc().TabOp( aRange, &rMark, rParam, bRecord, false );
2281  }
2282  else
2283  ErrorMessage(STR_NOMULTISELECT);
2284 }
2285 
2286 void ScViewFunc::MakeScenario( const OUString& rName, const OUString& rComment,
2287  const Color& rColor, ScScenarioFlags nFlags )
2288 {
2289  ScDocShell* pDocSh = GetViewData().GetDocShell();
2290  ScMarkData& rMark = GetViewData().GetMarkData();
2291  SCTAB nTab = GetViewData().GetTabNo();
2292 
2293  SCTAB nNewTab = pDocSh->MakeScenario( nTab, rName, rComment, rColor, nFlags, rMark );
2294  if (nFlags & ScScenarioFlags::CopyAll)
2295  SetTabNo( nNewTab, true ); // ScScenarioFlags::CopyAll -> visible
2296  else
2297  {
2298  SfxBindings& rBindings = GetViewData().GetBindings();
2299  rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar
2300  rBindings.Invalidate( SID_ROWCOL_SELCOUNT ); // Statusbar
2301  rBindings.Invalidate( SID_TABLES_COUNT );
2302  rBindings.Invalidate( SID_SELECT_SCENARIO );
2303  rBindings.Invalidate( FID_TABLE_SHOW );
2304  }
2305 }
2306 
2308 {
2309  ScEditableTester aTester( this );
2310  if (!aTester.IsEditable())
2311  {
2312  ErrorMessage(aTester.GetMessageId());
2313  return;
2314  }
2315 
2316  // Undo: apply attributes
2317 
2318  ScDocument& rDoc = GetViewData().GetDocument();
2319  ScPatternAttr aPattern( rDoc.GetPool() );
2320  aPattern.GetItemSet().Put( ScMergeFlagAttr( ScMF::Scenario ) );
2321  aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
2322  ApplySelectionPattern(aPattern);
2323 }
2324 
2325 void ScViewFunc::UseScenario( const OUString& rName )
2326 {
2327  ScDocShell* pDocSh = GetViewData().GetDocShell();
2328  SCTAB nTab = GetViewData().GetTabNo();
2329 
2330  DoneBlockMode();
2331  InitOwnBlockMode();
2332  pDocSh->UseScenario( nTab, rName );
2333 }
2334 
2335 // Insert table
2336 
2337 bool ScViewFunc::InsertTable( const OUString& rName, SCTAB nTab, bool bRecord )
2338 {
2339  // Order Table/Name is inverted for DocFunc
2340  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
2341  InsertTable( nTab, rName, bRecord, false );
2342  if (bSuccess)
2343  SetTabNo( nTab, true );
2344 
2345  return bSuccess;
2346 }
2347 
2348 // Insert tables
2349 
2350 void ScViewFunc::InsertTables(std::vector<OUString>& aNames, SCTAB nTab,
2351  SCTAB nCount, bool bRecord )
2352 {
2353  ScDocShell* pDocSh = GetViewData().GetDocShell();
2354  ScDocument& rDoc = pDocSh->GetDocument();
2355  if (bRecord && !rDoc.IsUndoEnabled())
2356  bRecord = false;
2357 
2358  weld::WaitObject aWait(GetViewData().GetDialogParent());
2359 
2360  if (bRecord)
2361  {
2362  rDoc.BeginDrawUndo(); // InsertTab creates a SdrUndoNewPage
2363  }
2364 
2365  bool bFlag=false;
2366 
2367  if(aNames.empty())
2368  {
2369  rDoc.CreateValidTabNames(aNames, nCount);
2370  }
2371  if (rDoc.InsertTabs(nTab, aNames))
2372  {
2373  pDocSh->Broadcast( ScTablesHint( SC_TABS_INSERTED, nTab, nCount ) );
2374  bFlag = true;
2375  }
2376 
2377  if (!bFlag)
2378  return;
2379 
2380  if (bRecord)
2381  pDocSh->GetUndoManager()->AddUndoAction(
2382  std::make_unique<ScUndoInsertTables>( pDocSh, nTab, std::move(aNames)));
2383 
2384  // Update views
2385 
2386  SetTabNo( nTab, true );
2387  pDocSh->PostPaintExtras();
2388  pDocSh->SetDocumentModified();
2389  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2390 }
2391 
2392 bool ScViewFunc::AppendTable( const OUString& rName, bool bRecord )
2393 {
2394  ScDocShell* pDocSh = GetViewData().GetDocShell();
2395  ScDocument& rDoc = pDocSh->GetDocument();
2396  if (bRecord && !rDoc.IsUndoEnabled())
2397  bRecord = false;
2398 
2399  weld::WaitObject aWait(GetViewData().GetDialogParent());
2400 
2401  if (bRecord)
2402  rDoc.BeginDrawUndo(); // InsertTab creates a SdrUndoNewPage
2403 
2404  if (rDoc.InsertTab( SC_TAB_APPEND, rName ))
2405  {
2406  SCTAB nTab = rDoc.GetTableCount()-1;
2407  if (bRecord)
2408  pDocSh->GetUndoManager()->AddUndoAction(
2409  std::make_unique<ScUndoInsertTab>( pDocSh, nTab, true, rName));
2410  GetViewData().InsertTab( nTab );
2411  SetTabNo( nTab, true );
2412  pDocSh->PostPaintExtras();
2413  pDocSh->SetDocumentModified();
2414  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2415  return true;
2416  }
2417  else
2418  {
2419  return false;
2420  }
2421 }
2422 
2423 void ScViewFunc::DeleteTable( SCTAB nTab, bool bRecord )
2424 {
2425  ScDocShell* pDocSh = GetViewData().GetDocShell();
2426  ScDocument& rDoc = pDocSh->GetDocument();
2427 
2428  bool bSuccess = pDocSh->GetDocFunc().DeleteTable( nTab, bRecord );
2429  if (bSuccess)
2430  {
2431  SCTAB nNewTab = nTab;
2432  if ( nNewTab >= rDoc.GetTableCount() )
2433  --nNewTab;
2434  SetTabNo( nNewTab, true );
2435  }
2436 }
2437 
2438 //only use this method for undo for now, all sheets must be connected
2439 //this method doesn't support undo for now, merge it when it with the other method later
2440 void ScViewFunc::DeleteTables( const SCTAB nTab, SCTAB nSheets )
2441 {
2442  ScDocShell* pDocSh = GetViewData().GetDocShell();
2443  ScDocument& rDoc = pDocSh->GetDocument();
2444  bool bVbaEnabled = rDoc.IsInVBAMode();
2445  SCTAB nNewTab = nTab;
2446  weld::WaitObject aWait(GetViewData().GetDialogParent());
2447 
2448  while ( nNewTab > 0 && !rDoc.IsVisible( nNewTab ) )
2449  --nNewTab;
2450 
2451  if (!rDoc.DeleteTabs(nTab, nSheets))
2452  return;
2453 
2454  if( bVbaEnabled )
2455  {
2456  for (SCTAB aTab = 0; aTab < nSheets; ++aTab)
2457  {
2458  OUString sCodeName;
2459  bool bHasCodeName = rDoc.GetCodeName( nTab + aTab, sCodeName );
2460  if ( bHasCodeName )
2461  VBA_DeleteModule( *pDocSh, sCodeName );
2462  }
2463  }
2464 
2465  pDocSh->Broadcast( ScTablesHint( SC_TABS_DELETED, nTab, nSheets ) );
2466  if ( nNewTab >= rDoc.GetTableCount() )
2467  nNewTab = rDoc.GetTableCount() - 1;
2468  SetTabNo( nNewTab, true );
2469 
2470  pDocSh->PostPaintExtras();
2471  pDocSh->SetDocumentModified();
2472 
2473  SfxApplication* pSfxApp = SfxGetpApp(); // Navigator
2474  pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2475  pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
2476  pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
2477 }
2478 
2479 bool ScViewFunc::DeleteTables(const vector<SCTAB> &TheTabs, bool bRecord )
2480 {
2481  ScDocShell* pDocSh = GetViewData().GetDocShell();
2482  ScDocument& rDoc = pDocSh->GetDocument();
2483  bool bVbaEnabled = rDoc.IsInVBAMode();
2484  SCTAB nNewTab = TheTabs.front();
2485  weld::WaitObject aWait(GetViewData().GetDialogParent());
2486  if (bRecord && !rDoc.IsUndoEnabled())
2487  bRecord = false;
2488  if ( bVbaEnabled )
2489  bRecord = false;
2490 
2491  while ( nNewTab > 0 && !rDoc.IsVisible( nNewTab ) )
2492  --nNewTab;
2493 
2494  bool bWasLinked = false;
2495  ScDocumentUniquePtr pUndoDoc;
2496  std::unique_ptr<ScRefUndoData> pUndoData;
2497  if (bRecord)
2498  {
2499  pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
2500  SCTAB nCount = rDoc.GetTableCount();
2501 
2502  OUString aOldName;
2503  for(size_t i=0; i<TheTabs.size(); ++i)
2504  {
2505  SCTAB nTab = TheTabs[i];
2506  if (i==0)
2507  pUndoDoc->InitUndo( rDoc, nTab,nTab, true,true ); // incl. column/fow flags
2508  else
2509  pUndoDoc->AddUndoTab( nTab,nTab, true,true ); // incl. column/fow flags
2510 
2511  rDoc.CopyToDocument(0,0,nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab, InsertDeleteFlags::ALL,false, *pUndoDoc );
2512  rDoc.GetName( nTab, aOldName );
2513  pUndoDoc->RenameTab( nTab, aOldName );
2514  if (rDoc.IsLinked(nTab))
2515  {
2516  bWasLinked = true;
2517  pUndoDoc->SetLink( nTab, rDoc.GetLinkMode(nTab), rDoc.GetLinkDoc(nTab),
2518  rDoc.GetLinkFlt(nTab), rDoc.GetLinkOpt(nTab),
2519  rDoc.GetLinkTab(nTab),
2520  rDoc.GetLinkRefreshDelay(nTab) );
2521  }
2522  if ( rDoc.IsScenario(nTab) )
2523  {
2524  pUndoDoc->SetScenario( nTab, true );
2525  OUString aComment;
2526  Color aColor;
2527  ScScenarioFlags nScenFlags;
2528  rDoc.GetScenarioData( nTab, aComment, aColor, nScenFlags );
2529  pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
2530  bool bActive = rDoc.IsActiveScenario( nTab );
2531  pUndoDoc->SetActiveScenario( nTab, bActive );
2532  }
2533  pUndoDoc->SetVisible( nTab, rDoc.IsVisible( nTab ) );
2534  pUndoDoc->SetTabBgColor( nTab, rDoc.GetTabBgColor(nTab) );
2535  auto pSheetEvents = rDoc.GetSheetEvents( nTab );
2536  pUndoDoc->SetSheetEvents( nTab, std::unique_ptr<ScSheetEvents>(pSheetEvents ? new ScSheetEvents(*pSheetEvents) : nullptr) );
2537  pUndoDoc->SetLayoutRTL( nTab, rDoc.IsLayoutRTL( nTab ) );
2538 
2539  if ( rDoc.IsTabProtected( nTab ) )
2540  pUndoDoc->SetTabProtection(nTab, rDoc.GetTabProtection(nTab));
2541 
2542  // Drawing-Layer is responsible for its Undo !!!
2543  // pUndoDoc->TransferDrawPage(rDoc, nTab,nTab);
2544  }
2545 
2546  pUndoDoc->AddUndoTab( 0, nCount-1 ); // all Tabs for references
2547 
2548  rDoc.BeginDrawUndo(); // DeleteTab creates a SdrUndoDelPage
2549 
2550  pUndoData.reset(new ScRefUndoData( &rDoc ));
2551  }
2552 
2553  bool bDelDone = false;
2554 
2555  for(int i=TheTabs.size()-1; i>=0; --i)
2556  {
2557  OUString sCodeName;
2558  bool bHasCodeName = rDoc.GetCodeName( TheTabs[i], sCodeName );
2559  if (rDoc.DeleteTab(TheTabs[i]))
2560  {
2561  bDelDone = true;
2562  if( bVbaEnabled && bHasCodeName )
2563  {
2564  VBA_DeleteModule( *pDocSh, sCodeName );
2565  }
2566  pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[i] ) );
2567  }
2568  }
2569  if (bRecord)
2570  {
2571  pDocSh->GetUndoManager()->AddUndoAction(
2572  std::make_unique<ScUndoDeleteTab>( GetViewData().GetDocShell(), TheTabs,
2573  std::move(pUndoDoc), std::move(pUndoData) ));
2574  }
2575 
2576  if (bDelDone)
2577  {
2578  if ( nNewTab >= rDoc.GetTableCount() )
2579  nNewTab = rDoc.GetTableCount() - 1;
2580 
2581  SetTabNo( nNewTab, true );
2582 
2583  if (bWasLinked)
2584  {
2585  pDocSh->UpdateLinks(); // update Link-Manager
2586  GetViewData().GetBindings().Invalidate(SID_LINKS);
2587  }
2588 
2589  pDocSh->PostPaintExtras();
2590  pDocSh->SetDocumentModified();
2591 
2592  SfxApplication* pSfxApp = SfxGetpApp(); // Navigator
2593  pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2594  pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
2595  pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
2596  }
2597  return bDelDone;
2598 }
2599 
2600 bool ScViewFunc::RenameTable( const OUString& rName, SCTAB nTab )
2601 {
2602  // order Table/Name is inverted for DocFunc
2603  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
2604  RenameTable( nTab, rName, true, false );
2605  if (bSuccess)
2606  {
2607  // the table name might be part of a formula
2608  GetViewData().GetViewShell()->UpdateInputHandler();
2609  }
2610  return bSuccess;
2611 }
2612 
2613 bool ScViewFunc::SetTabBgColor( const Color& rColor, SCTAB nTab )
2614 {
2615  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().SetTabBgColor( nTab, rColor, true, false );
2616  if (bSuccess)
2617  {
2618  GetViewData().GetViewShell()->UpdateInputHandler();
2619  }
2620  return bSuccess;
2621 }
2622 
2623 bool ScViewFunc::SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList )
2624 {
2625  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().SetTabBgColor( rUndoSetTabBgColorInfoList, false );
2626  if (bSuccess)
2627  {
2628  GetViewData().GetViewShell()->UpdateInputHandler();
2629  }
2630  return bSuccess;
2631 }
2632 
2633 void ScViewFunc::InsertAreaLink( const OUString& rFile,
2634  const OUString& rFilter, const OUString& rOptions,
2635  const OUString& rSource )
2636 {
2637  ScDocShell* pDocSh = GetViewData().GetDocShell();
2638  SCCOL nPosX = GetViewData().GetCurX();
2639  SCROW nPosY = GetViewData().GetCurY();
2640  SCTAB nTab = GetViewData().GetTabNo();
2641  ScAddress aPos( nPosX, nPosY, nTab );
2642 
2643  pDocSh->GetDocFunc().InsertAreaLink( rFile, rFilter, rOptions, rSource, aPos, 0/*nRefresh*/, false, false );
2644 }
2645 
2646 void ScViewFunc::InsertTableLink( const OUString& rFile,
2647  const OUString& rFilter, const OUString& rOptions,
2648  std::u16string_view rTabName )
2649 {
2650  OUString aFilterName = rFilter;
2651  OUString aOpt = rOptions;
2652  ScDocumentLoader aLoader( rFile, aFilterName, aOpt );
2653  if (aLoader.IsError())
2654  return;
2655 
2656  ScDocShell* pSrcSh = aLoader.GetDocShell();
2657  ScDocument& rSrcDoc = pSrcSh->GetDocument();
2658  SCTAB nTab = MAXTAB+1;
2659  if (rTabName.empty()) // no name given -> first table
2660  nTab = 0;
2661  else
2662  {
2663  OUString aTemp;
2664  SCTAB nCount = rSrcDoc.GetTableCount();
2665  for (SCTAB i=0; i<nCount; i++)
2666  {
2667  rSrcDoc.GetName( i, aTemp );
2668  if ( aTemp == rTabName )
2669  nTab = i;
2670  }
2671  }
2672 
2673  if ( nTab <= MAXTAB )
2674  ImportTables( pSrcSh, 1, &nTab, true,
2675  GetViewData().GetTabNo() );
2676 }
2677 
2678 // Copy/link tables from another document
2679 
2681  SCTAB nCount, const SCTAB* pSrcTabs, bool bLink,SCTAB nTab )
2682 {
2683  ScDocument& rSrcDoc = pSrcShell->GetDocument();
2684 
2685  ScDocShell* pDocSh = GetViewData().GetDocShell();
2686  ScDocument& rDoc = pDocSh->GetDocument();
2687  bool bUndo(rDoc.IsUndoEnabled());
2688 
2689  bool bError = false;
2690  bool bRefs = false;
2691  bool bName = false;
2692 
2693  if (rSrcDoc.GetDrawLayer())
2694  pDocSh->MakeDrawLayer();
2695 
2696  if (bUndo)
2697  rDoc.BeginDrawUndo(); // drawing layer must do its own undo actions
2698 
2699  SCTAB nInsCount = 0;
2700  SCTAB i;
2701  for( i=0; i<nCount; i++ )
2702  { // insert sheets first and update all references
2703  OUString aName;
2704  rSrcDoc.GetName( pSrcTabs[i], aName );
2705  rDoc.CreateValidTabName( aName );
2706  if ( !rDoc.InsertTab( nTab+i, aName ) )
2707  {
2708  bError = true; // total error
2709  break; // for
2710  }
2711  ++nInsCount;
2712  }
2713  for (i=0; i<nCount && !bError; i++)
2714  {
2715  SCTAB nSrcTab = pSrcTabs[i];
2716  SCTAB nDestTab1=nTab+i;
2717  sal_uLong nErrVal = pDocSh->TransferTab( *pSrcShell, nSrcTab, nDestTab1,
2718  false, false ); // no insert
2719 
2720  switch (nErrVal)
2721  {
2722  case 0: // internal error or full of errors
2723  bError = true;
2724  break;
2725  case 2:
2726  bRefs = true;
2727  break;
2728  case 3:
2729  bName = true;
2730  break;
2731  case 4:
2732  bRefs = bName = true;
2733  break;
2734  }
2735 
2736  }
2737 
2738  if (bLink)
2739  {
2740  sfx2::LinkManager* pLinkManager = rDoc.GetLinkManager();
2741 
2742  SfxMedium* pMed = pSrcShell->GetMedium();
2743  OUString aFileName = pMed->GetName();
2744  OUString aFilterName;
2745  if (pMed->GetFilter())
2746  aFilterName = pMed->GetFilter()->GetFilterName();
2747  OUString aOptions = ScDocumentLoader::GetOptions(*pMed);
2748 
2749  bool bWasThere = rDoc.HasLink( aFileName, aFilterName, aOptions );
2750 
2751  sal_uLong nRefresh = 0;
2752  OUString aTabStr;
2753  for (i=0; i<nInsCount; i++)
2754  {
2755  rSrcDoc.GetName( pSrcTabs[i], aTabStr );
2756  rDoc.SetLink( nTab+i, ScLinkMode::NORMAL,
2757  aFileName, aFilterName, aOptions, aTabStr, nRefresh );
2758  }
2759 
2760  if (!bWasThere) // Insert link only once per source document
2761  {
2762  ScTableLink* pLink = new ScTableLink( pDocSh, aFileName, aFilterName, aOptions, nRefresh );
2763  pLink->SetInCreate( true );
2764  pLinkManager->InsertFileLink( *pLink, sfx2::SvBaseLinkObjectType::ClientFile, aFileName, &aFilterName );
2765  pLink->Update();
2766  pLink->SetInCreate( false );
2767 
2768  SfxBindings& rBindings = GetViewData().GetBindings();
2769  rBindings.Invalidate( SID_LINKS );
2770  }
2771  }
2772 
2773  if (bUndo)
2774  {
2775  pDocSh->GetUndoManager()->AddUndoAction(
2776  std::make_unique<ScUndoImportTab>( pDocSh, nTab, nCount ) );
2777  }
2778 
2779  for (i=0; i<nInsCount; i++)
2780  GetViewData().InsertTab(nTab);
2781  SetTabNo(nTab,true);
2782  pDocSh->PostPaint( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB,
2784 
2785  SfxApplication* pSfxApp = SfxGetpApp();
2786  pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2787  pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
2788 
2789  pDocSh->PostPaintExtras();
2790  pDocSh->PostPaintGridAll();
2791  pDocSh->SetDocumentModified();
2792 
2793  if (bRefs)
2794  ErrorMessage(STR_ABSREFLOST);
2795  if (bName)
2796  ErrorMessage(STR_NAMECONFLICT);
2797 }
2798 
2799 // Move/Copy table to another document
2800 
2802  sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy, const OUString* pNewTabName )
2803 {
2804  ScDocument& rDoc = GetViewData().GetDocument();
2805  ScDocShell* pDocShell = GetViewData().GetDocShell();
2806  ScDocShell* pDestShell = nullptr;
2807  ScTabViewShell* pDestViewSh = nullptr;
2808  bool bUndo (rDoc.IsUndoEnabled());
2809  bool bRename = pNewTabName && !pNewTabName->isEmpty();
2810 
2811  bool bNewDoc = (nDestDocNo == SC_DOC_NEW);
2812  if ( bNewDoc )
2813  {
2814  nDestTab = 0; // firstly insert
2815 
2816  // execute without SfxCallMode::RECORD, because already contained in move command
2817 
2818  SfxStringItem aItem( SID_FILE_NAME, "private:factory/" STRING_SCAPP );
2819  SfxStringItem aTarget( SID_TARGETNAME, "_blank" );
2820 
2821  const SfxPoolItem* pRetItem = GetViewData().GetDispatcher().ExecuteList(
2822  SID_OPENDOC, SfxCallMode::API|SfxCallMode::SYNCHRON,
2823  { &aItem, &aTarget });
2824  if ( pRetItem )
2825  {
2826  if ( auto pObjectItem = dynamic_cast<const SfxObjectItem*>(pRetItem) )
2827  pDestShell = dynamic_cast<ScDocShell*>( pObjectItem->GetShell() );
2828  else if ( auto pViewFrameItem = dynamic_cast<const SfxViewFrameItem*>( pRetItem) )
2829  {
2830  SfxViewFrame* pFrm = pViewFrameItem->GetFrame();
2831  if (pFrm)
2832  pDestShell = dynamic_cast<ScDocShell*>( pFrm->GetObjectShell() );
2833  }
2834  if (pDestShell)
2835  pDestViewSh = pDestShell->GetBestViewShell();
2836  }
2837  }
2838  else
2839  pDestShell = ScDocShell::GetShellByNum( nDestDocNo );
2840 
2841  if (!pDestShell)
2842  {
2843  OSL_FAIL("Destination document not found !!!");
2844  return;
2845  }
2846 
2847  ScMarkData& rMark = GetViewData().GetMarkData();
2848  if (bRename && rMark.GetSelectCount() != 1)
2849  {
2850  // Custom sheet name is provided, but more than one sheet is selected.
2851  // We don't support this scenario at the moment.
2852  return;
2853  }
2854 
2855  ScDocument& rDestDoc = pDestShell->GetDocument();
2856 
2857  if (&rDestDoc != &rDoc)
2858  {
2859  if (bNewDoc)
2860  {
2861  while (rDestDoc.GetTableCount() > 1)
2862  rDestDoc.DeleteTab(0);
2863  rDestDoc.RenameTab( 0, "______42_____" );
2864  }
2865 
2866  SCTAB nTabCount = rDoc.GetTableCount();
2867  SCTAB nTabSelCount = rMark.GetSelectCount();
2868 
2869  vector<SCTAB> TheTabs;
2870 
2871  for(SCTAB i=0; i<nTabCount; ++i)
2872  {
2873  if(rMark.GetTableSelect(i))
2874  {
2875  OUString aTabName;
2876  rDoc.GetName( i, aTabName);
2877  TheTabs.push_back(i);
2878  for(SCTAB j=i+1;j<nTabCount;j++)
2879  {
2880  if((!rDoc.IsVisible(j)) && rDoc.IsScenario(j))
2881  {
2882  rDoc.GetName( j, aTabName);
2883  TheTabs.push_back(j);
2884  i=j;
2885  }
2886  else break;
2887  }
2888  }
2889  }
2890 
2891  GetFrameWin()->EnterWait();
2892 
2893  if (rDoc.GetDrawLayer())
2894  pDestShell->MakeDrawLayer();
2895 
2896  if (!bNewDoc && bUndo)
2897  rDestDoc.BeginDrawUndo(); // drawing layer must do its own undo actions
2898 
2899  sal_uLong nErrVal =1;
2900  if(nDestTab==SC_TAB_APPEND)
2901  nDestTab=rDestDoc.GetTableCount();
2902  SCTAB nDestTab1=nDestTab;
2903  ScClipParam aParam;
2904  for( size_t j=0; j<TheTabs.size(); ++j, ++nDestTab1 )
2905  { // insert sheets first and update all references
2906  OUString aName;
2907  if (bRename)
2908  aName = *pNewTabName;
2909  else
2910  rDoc.GetName( TheTabs[j], aName );
2911 
2912  rDestDoc.CreateValidTabName( aName );
2913  if ( !rDestDoc.InsertTab( nDestTab1, aName ) )
2914  {
2915  nErrVal = 0; // total error
2916  break; // for
2917  }
2918  ScRange aRange( 0, 0, TheTabs[j], rDoc.MaxCol(), rDoc.MaxRow(), TheTabs[j] );
2919  aParam.maRanges.push_back(aRange);
2920  }
2921  rDoc.SetClipParam(aParam);
2922  if ( nErrVal > 0 )
2923  {
2924  nDestTab1 = nDestTab;
2925  for(SCTAB nTab : TheTabs)
2926  {
2927  nErrVal = pDestShell->TransferTab( *pDocShell, nTab, nDestTab1, false, false );
2928  nDestTab1++;
2929  }
2930  }
2931  if (!bNewDoc && bUndo)
2932  {
2933  OUString sName;
2934  rDestDoc.GetName(nDestTab, sName);
2935  pDestShell->GetUndoManager()->AddUndoAction(
2936  std::make_unique<ScUndoImportTab>( pDestShell, nDestTab,
2937  static_cast<SCTAB>(TheTabs.size())));
2938 
2939  }
2940  else
2941  {
2942  pDestShell->GetUndoManager()->Clear();
2943  }
2944 
2945  GetFrameWin()->LeaveWait();
2946  switch (nErrVal)
2947  {
2948  case 0: // internal error or full of errors
2949  {
2950  ErrorMessage(STR_TABINSERT_ERROR);
2951  return;
2952  }
2953  case 2:
2954  ErrorMessage(STR_ABSREFLOST);
2955  break;
2956  case 3:
2957  ErrorMessage(STR_NAMECONFLICT);
2958  break;
2959  case 4:
2960  {
2961  ErrorMessage(STR_ABSREFLOST);
2962  ErrorMessage(STR_NAMECONFLICT);
2963  }
2964  break;
2965  default:
2966  break;
2967  }
2968 
2969  if (!bCopy)
2970  {
2971  if(nTabCount!=nTabSelCount)
2972  DeleteTables(TheTabs); // incl. Paint & Undo
2973  else
2974  ErrorMessage(STR_TABREMOVE_ERROR);
2975  }
2976 
2977  if (bNewDoc)
2978  {
2979  // ChartListenerCollection must be updated before DeleteTab
2980  if ( rDestDoc.IsChartListenerCollectionNeedsUpdate() )
2981  rDestDoc.UpdateChartListenerCollection();
2982 
2983  SCTAB nNumTabsInserted = static_cast<SCTAB>(TheTabs.size());
2984  pDestShell->Broadcast( ScTablesHint( SC_TABS_INSERTED, 0, nNumTabsInserted ) );
2985 
2986  rDestDoc.DeleteTab( nNumTabsInserted ); // old first table
2987  pDestShell->Broadcast( ScTablesHint( SC_TAB_DELETED, nNumTabsInserted ) );
2988 
2989  if (pDestViewSh)
2990  {
2991  // Make sure to clear the cached page view after sheet
2992  // deletion, which still points to the sdr page belonging to
2993  // the deleted sheet.
2994  SdrView* pSdrView = pDestViewSh->GetScDrawView();
2995  if (pSdrView)
2996  pSdrView->ClearPageView();
2997 
2998  pDestViewSh->TabChanged(); // pages on the drawing layer
2999  }
3000  pDestShell->PostPaint( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB,
3003  // PaintPartFlags::Size for outline
3004  }
3005  else
3006  {
3007  pDestShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestTab ) );
3008  pDestShell->PostPaintExtras();
3009  pDestShell->PostPaintGridAll();
3010  }
3011 
3012  TheTabs.clear();
3013 
3014  pDestShell->SetDocumentModified();
3015  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
3016  }
3017  else
3018  {
3019  // Move or copy within the same document.
3020  SCTAB nTabCount = rDoc.GetTableCount();
3021 
3022  unique_ptr< vector<SCTAB> > pSrcTabs(new vector<SCTAB>);
3023  unique_ptr< vector<SCTAB> > pDestTabs(new vector<SCTAB>);
3024  unique_ptr< vector<OUString> > pTabNames(new vector<OUString>);
3025  unique_ptr< vector<OUString> > pDestNames;
3026  pSrcTabs->reserve(nTabCount);
3027  pDestTabs->reserve(nTabCount);
3028  pTabNames->reserve(nTabCount);
3029  OUString aDestName;
3030 
3031  for(SCTAB i=0;i<nTabCount;i++)
3032  {
3033  if(rMark.GetTableSelect(i))
3034  {
3035  OUString aTabName;
3036  rDoc.GetName( i, aTabName);
3037  pTabNames->push_back(aTabName);
3038 
3039  for(SCTAB j=i+1;j<nTabCount;j++)
3040  {
3041  if((!rDoc.IsVisible(j)) && rDoc.IsScenario(j))
3042  {
3043  rDoc.GetName( j, aTabName);
3044  pTabNames->push_back(aTabName);
3045  i=j;
3046  }
3047  else break;
3048  }
3049  }
3050  }
3051 
3052  if (bCopy && bUndo)
3053  rDoc.BeginDrawUndo(); // drawing layer must do its own undo actions
3054 
3055  rDoc.GetName( nDestTab, aDestName);
3056  SCTAB nDestTab1=nDestTab;
3057  SCTAB nMovTab=0;
3058  for (size_t j = 0, n = pTabNames->size(); j < n; ++j)
3059  {
3060  nTabCount = rDoc.GetTableCount();
3061  const OUString& rStr = (*pTabNames)[j];
3062  if(!rDoc.GetTable(rStr,nMovTab))
3063  {
3064  nMovTab=nTabCount;
3065  }
3066  if(!rDoc.GetTable(aDestName,nDestTab1))
3067  {
3068  nDestTab1=nTabCount;
3069  }
3070  pDocShell->MoveTable( nMovTab, nDestTab1, bCopy, false ); // Undo is here
3071 
3072  // tdf#43175 - Adjust chart references on every copied sheet
3073  if (bCopy)
3074  {
3075  // New position of source table after moving
3076  SCTAB nSrcTab = (nDestTab1 <= nMovTab) ? nMovTab + 1 : nMovTab;
3077  //#i29848# adjust references to data on the copied sheet
3079  nDestTab1);
3080  }
3081 
3082  if(bCopy && rDoc.IsScenario(nMovTab))
3083  {
3084  OUString aComment;
3085  Color aColor;
3086  ScScenarioFlags nFlags;
3087 
3088  rDoc.GetScenarioData(nMovTab, aComment,aColor, nFlags);
3089  rDoc.SetScenario(nDestTab1,true);
3090  rDoc.SetScenarioData(nDestTab1,aComment,aColor,nFlags);
3091  bool bActive = rDoc.IsActiveScenario(nMovTab );
3092  rDoc.SetActiveScenario( nDestTab1, bActive );
3093  bool bVisible=rDoc.IsVisible(nMovTab);
3094  rDoc.SetVisible(nDestTab1,bVisible );
3095  }
3096 
3097  pSrcTabs->push_back(nMovTab);
3098 
3099  if(!bCopy)
3100  {
3101  if(!rDoc.GetTable(rStr,nDestTab1))
3102  {
3103  nDestTab1=nTabCount;
3104  }
3105  }
3106 
3107  pDestTabs->push_back(nDestTab1);
3108  }
3109 
3110  // Rename must be done after all sheets have been moved.
3111  if (bRename)
3112  {
3113  pDestNames.reset(new vector<OUString>);
3114  size_t n = pDestTabs->size();
3115  pDestNames->reserve(n);
3116  for (size_t j = 0; j < n; ++j)
3117  {
3118  SCTAB nRenameTab = (*pDestTabs)[j];
3119  OUString aTabName = *pNewTabName;
3120  rDoc.CreateValidTabName( aTabName );
3121  pDestNames->push_back(aTabName);
3122  rDoc.RenameTab(nRenameTab, aTabName);
3123  }
3124  }
3125  else
3126  // No need to keep this around when we are not renaming.
3127  pTabNames.reset();
3128 
3129  SCTAB nTab = GetViewData().GetTabNo();
3130 
3131  if (bUndo)
3132  {
3133  if (bCopy)
3134  {
3135  pDocShell->GetUndoManager()->AddUndoAction(
3136  std::make_unique<ScUndoCopyTab>(
3137  pDocShell, std::move(pSrcTabs), std::move(pDestTabs), std::move(pDestNames)));
3138  }
3139  else
3140  {
3141  pDocShell->GetUndoManager()->AddUndoAction(
3142  std::make_unique<ScUndoMoveTab>(
3143  pDocShell, std::move(pSrcTabs), std::move(pDestTabs), std::move(pTabNames), std::move(pDestNames)));
3144  }
3145  }
3146 
3147  SCTAB nNewTab = nDestTab;
3148  if (nNewTab == SC_TAB_APPEND)
3149  nNewTab = rDoc.GetTableCount()-1;
3150  else if (!bCopy && nTab<nDestTab)
3151  nNewTab--;
3152 
3153  SetTabNo( nNewTab, true );
3154  }
3155 }
3156 
3157 void ScViewFunc::ShowTable( const std::vector<OUString>& rNames )
3158 {
3159  ScDocShell* pDocSh = GetViewData().GetDocShell();
3160  ScDocument& rDoc = pDocSh->GetDocument();
3161  bool bUndo(rDoc.IsUndoEnabled());
3162 
3163  std::vector<SCTAB> undoTabs;
3164  SCTAB nPos = 0;
3165 
3166  bool bFound(false);
3167 
3168  for (const OUString& aName : rNames)
3169  {
3170  if (rDoc.GetTable(aName, nPos))
3171  {
3172  rDoc.SetVisible( nPos, true );
3173  SetTabNo( nPos, true );
3174  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
3175  if (!bFound)
3176  bFound = true;
3177  if (bUndo)
3178  undoTabs.push_back(nPos);
3179  }
3180  }
3181  if (bFound)
3182  {
3183  if (bUndo)
3184  {
3185  pDocSh->GetUndoManager()->AddUndoAction( std::make_unique<ScUndoShowHideTab>( pDocSh, std::move(undoTabs), true ) );
3186  }
3187  pDocSh->PostPaint(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Extras);
3188  pDocSh->SetDocumentModified();
3189  }
3190 }
3191 
3192 void ScViewFunc::HideTable( const ScMarkData& rMark, SCTAB nTabToSelect )
3193 {
3194  ScDocShell* pDocSh = GetViewData().GetDocShell();
3195  ScDocument& rDoc = pDocSh->GetDocument();
3196  bool bUndo(rDoc.IsUndoEnabled());
3197  SCTAB nVisible = 0;
3198  SCTAB nTabCount = rDoc.GetTableCount();
3199 
3200  SCTAB nTabSelCount = rMark.GetSelectCount();
3201 
3202  // check to make sure we won't hide all sheets. we need at least one visible at all times.
3203  for ( SCTAB i=0; i < nTabCount && nVisible <= nTabSelCount ; i++ )
3204  if (rDoc.IsVisible(i))
3205  ++nVisible;
3206 
3207  if (nVisible <= nTabSelCount)
3208  return;
3209 
3210  std::vector<SCTAB> undoTabs;
3211 
3212  // need to take a copy of selectedtabs since it is modified in the loop
3213  const ScMarkData::MarkedTabsType selectedTabs = rMark.GetSelectedTabs();
3214  for (const SCTAB& nTab : selectedTabs)
3215  {
3216  if (rDoc.IsVisible( nTab ))
3217  {
3218  rDoc.SetVisible( nTab, false );
3219  // Update views
3220  pDocSh->Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) );
3221  SetTabNo( nTab, true );
3222  // Store for undo
3223  if (bUndo)
3224  undoTabs.push_back(nTab);
3225  }
3226  }
3227 
3228  if (nTabToSelect != -1)
3229  SetTabNo(nTabToSelect);
3230 
3231  if (bUndo)
3232  {
3233  pDocSh->GetUndoManager()->AddUndoAction( std::make_unique<ScUndoShowHideTab>( pDocSh, std::move(undoTabs), false ) );
3234  }
3235 
3236  // Update views
3237  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
3238  pDocSh->PostPaint(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Extras);
3239  pDocSh->SetDocumentModified();
3240 }
3241 
3242 void ScViewFunc::InsertSpecialChar( const OUString& rStr, const vcl::Font& rFont )
3243 {
3244  ScEditableTester aTester( this );
3245  if (!aTester.IsEditable())
3246  {
3247  ErrorMessage(aTester.GetMessageId());
3248  return;
3249  }
3250 
3251  const sal_Unicode* pChar = rStr.getStr();
3252  ScTabViewShell* pViewShell = GetViewData().GetViewShell();
3253  SvxFontItem aFontItem( rFont.GetFamilyType(),
3254  rFont.GetFamilyName(),
3255  rFont.GetStyleName(),
3256  rFont.GetPitch(),
3257  rFont.GetCharSet(),
3258  ATTR_FONT );
3259 
3260  // if string contains WEAK characters, set all fonts
3261  SvtScriptType nScript;
3262  ScDocument& rDoc = GetViewData().GetDocument();
3263  if ( rDoc.HasStringWeakCharacters( rStr ) )
3264  nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
3265  else
3266  nScript = rDoc.GetStringScriptType( rStr );
3267 
3268  SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, pViewShell->GetPool() );
3269  aSetItem.PutItemForScriptType( nScript, aFontItem );
3270  ApplyUserItemSet( aSetItem.GetItemSet() );
3271 
3272  while ( *pChar )
3273  pViewShell->TabKeyInput( KeyEvent( *(pChar++), vcl::KeyCode() ) );
3274 }
3275 
3276 void ScViewFunc::UpdateLineAttrs( SvxBorderLine& rLine,
3277  const SvxBorderLine* pDestLine,
3278  const SvxBorderLine* pSrcLine,
3279  bool bColor )
3280 {
3281  if ( !(pSrcLine && pDestLine) )
3282  return;
3283 
3284  if ( bColor )
3285  {
3286  rLine.SetColor ( pSrcLine->GetColor() );
3287  rLine.SetBorderLineStyle(pDestLine->GetBorderLineStyle());
3288  rLine.SetWidth ( pDestLine->GetWidth() );
3289  }
3290  else
3291  {
3292  rLine.SetColor ( pDestLine->GetColor() );
3293  rLine.SetBorderLineStyle(pSrcLine->GetBorderLineStyle());
3294  rLine.SetWidth ( pSrcLine->GetWidth() );
3295  }
3296 }
3297 
3298 #define SET_LINE_ATTRIBUTES(LINE,BOXLINE) \
3299  pBoxLine = aBoxItem.Get##LINE(); \
3300  if ( pBoxLine ) \
3301  { \
3302  if ( pLine ) \
3303  { \
3304  UpdateLineAttrs( aLine, pBoxLine, pLine, bColorOnly ); \
3305  aBoxItem.SetLine( &aLine, BOXLINE ); \
3306  } \
3307  else \
3308  aBoxItem.SetLine( nullptr, BOXLINE ); \
3309  }
3310 
3311 void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine,
3312  bool bColorOnly )
3313 {
3314  // Not editable only due to a matrix? Attribute is ok anyhow.
3315  bool bOnlyNotBecauseOfMatrix;
3316  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
3317  {
3318  ErrorMessage(STR_PROTECTIONERR);
3319  return;
3320  }
3321 
3322  ScDocument& rDoc = GetViewData().GetDocument();
3323  ScMarkData aFuncMark( GetViewData().GetMarkData() ); // local copy for UnmarkFiltered
3324  ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
3325  ScDocShell* pDocSh = GetViewData().GetDocShell();
3326  const ScPatternAttr* pSelAttrs = GetSelectionPattern();
3327  const SfxItemSet& rSelItemSet = pSelAttrs->GetItemSet();
3328 
3329  const SfxPoolItem* pBorderAttr = nullptr;
3330  SfxItemState eItemState = rSelItemSet.GetItemState( ATTR_BORDER, true, &pBorderAttr );
3331 
3332  const SfxPoolItem* pTLBRItem = nullptr;
3333  SfxItemState eTLBRState = rSelItemSet.GetItemState( ATTR_BORDER_TLBR, true, &pTLBRItem );
3334 
3335  const SfxPoolItem* pBLTRItem = nullptr;
3336  SfxItemState eBLTRState = rSelItemSet.GetItemState( ATTR_BORDER_BLTR, true, &pBLTRItem );
3337 
3338  // any of the lines visible?
3339  if( !((eItemState != SfxItemState::DEFAULT) || (eTLBRState != SfxItemState::DEFAULT) || (eBLTRState != SfxItemState::DEFAULT)) )
3340  return;
3341 
3342  // none of the lines don't care?
3343  if( (eItemState != SfxItemState::DONTCARE) && (eTLBRState != SfxItemState::DONTCARE) && (eBLTRState != SfxItemState::DONTCARE) )
3344  {
3347 
3348  SvxBorderLine aLine;
3349 
3350  if( pBorderAttr )
3351  {
3352  const SvxBorderLine* pBoxLine = nullptr;
3353  SvxBoxItem aBoxItem( *static_cast<const SvxBoxItem*>(pBorderAttr) );
3354  SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
3355 
3356  // here pBoxLine is used
3357  SET_LINE_ATTRIBUTES(Top,SvxBoxItemLine::TOP)
3358  SET_LINE_ATTRIBUTES(Bottom,SvxBoxItemLine::BOTTOM)
3359  SET_LINE_ATTRIBUTES(Left,SvxBoxItemLine::LEFT)
3360  SET_LINE_ATTRIBUTES(Right,SvxBoxItemLine::RIGHT)
3361 
3362  aBoxInfoItem.SetLine( aBoxItem.GetTop(), SvxBoxInfoItemLine::HORI );
3363  aBoxInfoItem.SetLine( aBoxItem.GetLeft(), SvxBoxInfoItemLine::VERT );
3364  aBoxInfoItem.ResetFlags(); // set Lines to Valid
3365 
3366  aOldSet.Put( *pBorderAttr );
3367  aNewSet.Put( aBoxItem );
3368  aNewSet.Put( aBoxInfoItem );
3369  }
3370 
3371  if( pTLBRItem && static_cast<const SvxLineItem*>(pTLBRItem)->GetLine() )
3372  {
3373  SvxLineItem aTLBRItem( *static_cast<const SvxLineItem*>(pTLBRItem) );
3374  UpdateLineAttrs( aLine, aTLBRItem.GetLine(), pLine, bColorOnly );
3375  aTLBRItem.SetLine( &aLine );
3376  aOldSet.Put( *pTLBRItem );
3377  aNewSet.Put( aTLBRItem );
3378  }
3379 
3380  if( pBLTRItem && static_cast<const SvxLineItem*>(pBLTRItem)->GetLine() )
3381  {
3382  SvxLineItem aBLTRItem( *static_cast<const SvxLineItem*>(pBLTRItem) );
3383  UpdateLineAttrs( aLine, aBLTRItem.GetLine(), pLine, bColorOnly );
3384  aBLTRItem.SetLine( &aLine );
3385  aOldSet.Put( *pBLTRItem );
3386  aNewSet.Put( aBLTRItem );
3387  }
3388 
3389  ApplyAttributes( &aNewSet, &aOldSet );
3390  }
3391  else // if ( eItemState == SfxItemState::DONTCARE )
3392  {
3393  aFuncMark.MarkToMulti();
3394  rDoc.ApplySelectionLineStyle( aFuncMark, pLine, bColorOnly );
3395  }
3396 
3397  ScRange aMarkRange;
3398  aFuncMark.GetMultiMarkArea( aMarkRange );
3399  SCCOL nStartCol = aMarkRange.aStart.Col();
3400  SCROW nStartRow = aMarkRange.aStart.Row();
3401  SCTAB nStartTab = aMarkRange.aStart.Tab();
3402  SCCOL nEndCol = aMarkRange.aEnd.Col();
3403  SCROW nEndRow = aMarkRange.aEnd.Row();
3404  SCTAB nEndTab = aMarkRange.aEnd.Tab();
3405  pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
3406  nEndCol, nEndRow, nEndTab,
3408 
3409  pDocSh->UpdateOle(GetViewData());
3410  pDocSh->SetDocumentModified();
3411 }
3412 
3413 #undef SET_LINE_ATTRIBUTES
3414 
3416 {
3417  ScDocument& rDoc = GetViewData().GetDocument();
3418  sal_uLong nIndex = rDoc.AddValidationEntry(rNew); // for it there is no Undo
3419  SfxUInt32Item aItem( ATTR_VALIDDATA, nIndex );
3420 
3421  ApplyAttr( aItem ); // with Paint and Undo...
3422 }
3423 
3424 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SC_DLLPUBLIC OUString GetLinkDoc(SCTAB nTab) const
Definition: documen3.cxx:511
void FillTabMarked(SCTAB nSrcTab, const ScMarkData &rMark, InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink)
Definition: document.cxx:3327
ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
Definition: address.cxx:1775
std::shared_ptr< SfxDialogController > & GetController()
static ScAutoSum lcl_GetAutoSumForColumnRange(ScDocument &rDoc, ScRangeList &rRangeList, const ScRange &rRange)
Definition: viewfun2.cxx:363
SC_DLLPUBLIC void InsertPageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
Definition: viewfun2.cxx:941
OUString GetLinkOpt(SCTAB nTab) const
Definition: documen3.cxx:525
#define SC_PF_TESTMERGE
Definition: docsh.hxx:77
void BeginDrawUndo()
Definition: documen9.cxx:60
formula::FormulaToken * AddDoubleReference(const ScComplexRefData &rRef)
Definition: token.cxx:2281
void UpdateLinks() override
Definition: docsh6.cxx:319
constexpr double nPPTY
void UpdatePageBreaks(SCTAB nTab, const ScRange *pUserArea=nullptr)
Definition: document.cxx:6247
bool InsertTable(const OUString &rName, SCTAB nTabNr, bool bRecord=true)
Definition: viewfun2.cxx:2337
OUString GetColRowString() const
Create a human-readable string representation of the cell address.
Definition: address.cxx:2497
void FillResults(ScDocument &rDoc, const ScRangeList &rMatchedRanges, bool bCellNotes, bool bEmptyCells)
void MarkToSimple()
Definition: markdata.cxx:236
const std::vector< editeng::MisspellRanges > * GetAutoSpellData(SCCOL nPosX, SCROW nPosY)
Definition: gridwin.cxx:5715
bool HasLink(std::u16string_view rDoc, std::u16string_view rFilter, std::u16string_view rOptions) const
Definition: documen3.cxx:554
sal_Int32 nIndex
double GetPPTY() const
Definition: sizedev.hxx:42
void MoveTable(sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy, const OUString *pNewTabName=nullptr)
Definition: viewfun2.cxx:2801
OpCode GetOuterFuncOpCode() const
ScAddress aStart
Definition: address.hxx:499
SC_DLLPUBLIC void ApplyPatternIfNumberformatIncompatible(const ScRange &rRange, const ScMarkData &rMark, const ScPatternAttr &rPattern, SvNumFormatType nNewType)
Definition: document.cxx:4825
bool bVisible
SC_DLLPUBLIC void SetScenario(SCTAB nTab, bool bFlag)
Definition: documen3.cxx:426
bool AdjustBlockHeight(bool bPaint=true, ScMarkData *pMarkData=nullptr)
Definition: viewfun2.cxx:114
void RemoveManualBreaks()
Definition: viewfun2.cxx:975
void SetSelectionFrameLines(const ::editeng::SvxBorderLine *pLine, bool bColorOnly)
Definition: viewfun2.cxx:3311
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1914
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: docsh3.cxx:451
void InsertTableLink(const OUString &rFile, const OUString &rFilter, const OUString &rOptions, std::u16string_view rTabName)
Definition: viewfun2.cxx:2646
SfxChildWindow * GetChildWindow(sal_uInt16)
SC_DLLPUBLIC ScLinkMode GetLinkMode(SCTAB nTab) const
Definition: documen3.cxx:504
#define STRING_SCAPP
Definition: global.hxx:56
const OUString & GetFamilyName() const
void PutItemForScriptType(SvtScriptType nScriptType, const SfxPoolItem &rItem)
bool IsPrinter() const
Definition: sizedev.hxx:43
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:89
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
SCROW Row() const
Definition: address.hxx:261
void PostPaintGridAll()
Definition: docsh3.cxx:183
void MarkToMulti()
Definition: markdata.cxx:223
bool GetAutoSumArea(ScRangeList &rRangeList)
Definition: viewfun2.cxx:478
bool AppendTable(const OUString &rName, bool bRecord=true)
Definition: viewfun2.cxx:2392
FillDir
Definition: global.hxx:318
void SetPrintRanges(bool bEntireSheet, const OUString *pPrint, const OUString *pRepCol, const OUString *pRepRow, bool bAddPrint)
Definition: viewfun2.cxx:1014
void FillTab(InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink)
Definition: viewfun2.cxx:1638
std::unique_ptr< ContentProperties > pData
const OUString & GetStyleName() const
signed char sal_Int8
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
Definition: documen3.cxx:877
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
Definition: documen9.cxx:195
SC_DLLPUBLIC bool InsertTabs(SCTAB nPos, const std::vector< OUString > &rNames, bool bNamesValid=false)
Definition: document.cxx:592
void SetMultiMarkArea(const ScRange &rRange, bool bMark=true, bool bSetupMulti=false)
Definition: markdata.cxx:121
ScScenarioFlags
Definition: global.hxx:236
void ResetMark()
Definition: markdata.cxx:84
SC_DLLPUBLIC bool MergeCells(const ScCellMergeOption &rOption, bool bContents, bool bRecord, bool bApi, bool bEmptyMergedCells=false)
Definition: docfunc.cxx:4928
void GetCellSelection(std::vector< tools::Rectangle > &rLogicRects)
Get the cell selection, coordinates are in logic units.
Definition: gridwin.cxx:6303
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, std::u16string_view rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
const OUString & GetName() const
ScTokenArray * GetCode()
sal_uIntPtr sal_uLong
SCCOL GetMaxColCount() const
Definition: sheetlimits.hxx:63
SC_DLLPUBLIC void ClearPrintRanges(SCTAB nTab)
Removes all print ranges.
Definition: document.cxx:6329
ocSubTotal
ocOpen
sal_Int64 n
void ApplySelectionLineStyle(const ScMarkData &rMark, const ::editeng::SvxBorderLine *pLine, bool bColorOnly)
Definition: document.cxx:4913
void ResetAutoSpellForContentChange()
Definition: gridwin.cxx:5701
void SetValidation(const ScValidationData &rNew)
Definition: viewfun2.cxx:3415
ScMergeCellsOption GetMergeCellsOption() const
std::vector< sc::ColRowSpan > GetMarkedRowSpans() const
Definition: markdata.cxx:478
aBuf
SvNumFormatType GetType(sal_uInt32 nFIndex) const
void DeleteTable(SCTAB nTabNr, bool bRecord=true)
Definition: viewfun2.cxx:2423
void SetDocumentModified()
Definition: docsh.cxx:2941
const SfxItemSet & GetItemSet() const
void PostPaintExtras()
Definition: docsh3.cxx:198
void EnterBlock(const OUString &rString, const EditTextObject *pData)
Definition: viewfun2.cxx:851
void Solve(const ScSolveParam &rParam)
Definition: viewfun2.cxx:2203
static ScAutoSum lcl_GetAutoSumForRowRange(ScDocument &rDoc, ScRangeList &rRangeList, const ScRange &rRange)
Definition: viewfun2.cxx:410
SC_DLLPUBLIC void SetRepeatColRange(SCTAB nTab, std::unique_ptr< ScRange > pNew)
Definition: document.cxx:6347
constexpr TypedWhichId< SvxBoxInfoItem > ATTR_BORDER_INNER(151)
bool DeleteTable(SCTAB nTab, bool bRecord)
Definition: docfunc.cxx:3314
void InitRangeRel(const ScDocument &rDoc, const ScRange &rRange, const ScAddress &rPos)
Definition: refdata.hxx:135
ScAddress aEnd
Definition: address.hxx:500
SC_DLLPUBLIC bool DeleteTabs(SCTAB nTab, SCTAB nSheets)
Definition: document.cxx:761
bool FillSimple(const ScRange &rRange, const ScMarkData *pTabMark, FillDir eDir, bool bApi)
Definition: docfunc.cxx:4540
ScDocument & GetDocument() const
Definition: viewdata.hxx:379
void SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
Update the cell selection according to what handles have been dragged.
Definition: gridwin4.cxx:1568
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
void SetLine(const editeng::SvxBorderLine *pNew)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:984
#define SC_TAB_INSERTED
Definition: uiitems.hxx:75
void Invalidate(sal_uInt16 nId)
void TabChanged(bool bSameTabButMoved=false)
Called after moving, copying, inserting or deleting a sheet.
Definition: tabview5.cxx:282
ocCount
ocMin
bool IsLinked(SCTAB nTab) const
Definition: documen3.cxx:485
virtual SfxObjectShell * GetObjectShell() override
bool HasStringWeakCharacters(const OUString &rString)
Definition: documen6.cxx:51
const MarkedTabsType & GetSelectedTabs() const
Definition: markdata.hxx:97
RET_CANCEL
SC_DLLPUBLIC void SetVisible(SCTAB nTab, bool bVisible)
Definition: document.cxx:901
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:494
sal_uLong TransferTab(ScDocShell &rSrcDocShell, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew, bool bNotifyAndPaint)
Definition: docsh5.cxx:854
bool Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, SCCOL nVCol, SCROW nVRow, SCTAB nVTab, const OUString &sValStr, double &nX)
(Goal Seek) Find a value of x that is a root of f(x)
Definition: documen4.cxx:71
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5205
std::unique_ptr< ScPrintRangeSaver > CreatePrintRangeSaver() const
Definition: document.cxx:6359
static void notifyAllViewsSheetGeomInvalidation(const SfxViewShell *pForViewShell, bool bColumns, bool bRows, bool bSizes, bool bHidden, bool bFiltered, bool bGroups, SCTAB nCurrentTabIndex)
Emits a LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY for all views whose current tab is equal to nCurrentTa...
Definition: tabvwshc.cxx:556
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
Definition: documen6.cxx:76
void ConvertFormulaToValue()
Definition: viewfun2.cxx:1829
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4192
FontFamily GetFamilyType()
void SetClipParam(const ScClipParam &rParam)
Definition: document.cxx:2573
#define SC_DOC_NEW
Definition: document.hxx:239
SfxApplication * SfxGetpApp()
bool RenameTable(const OUString &rName, SCTAB nTabNr)
Definition: viewfun2.cxx:2600
Internal use only (d&d undo): do not delete caption objects of cell notes.
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6087
void GetMarkArea(ScRange &rRange) const
Definition: markdata.cxx:111
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2927
RET_NO
::std::set< SCTAB > maTabs
static UITestLogger & getInstance()
void InsertTables(std::vector< OUString > &aNames, SCTAB nTab, SCTAB nCount, bool bRecord=true)
Definition: viewfun2.cxx:2350
void logEvent(const EventDescription &rDescription)
static bool lcl_extendMergeRange(ScCellMergeOption &rOption, const ScRange &rRange)
Definition: viewfun2.cxx:1281
sal_uInt16 sal_Unicode
static sal_Int8 GetSubTotal(const OpCode eCode)
Definition: viewfun2.cxx:457
RET_YES
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
Definition: document.cxx:853
void FillSeries(FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, double fStart, double fStep, double fMax)
Definition: viewfun2.cxx:1406
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:872
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:314
SCTAB GetSelectCount() const
Definition: markdata.cxx:194
bool IsMultiMarked() const
Definition: markdata.hxx:82
SvxSearchCellType GetCellType() const
OpCode
SfxFrame & GetFrame() const
int nCount
FillDateCmd
Definition: global.hxx:343
void ConvertFormulaToValue(const ScRange &rRange, bool bInteraction)
Definition: docfunc.cxx:5724
void TransliterateText(TransliterationFlags nType)
Definition: viewfun2.cxx:1840
void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, InsertDeleteFlags nFlags, bool bMarked, ScDocument &rDestDoc, const ScMarkData *pMarks=nullptr, bool bColRowFlags=true)
Definition: document.cxx:2050
#define SC_AUTOSUM_MAXCOUNT
Definition: viewfun2.cxx:300
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
ScDocShell * GetDocShell()
Definition: tablink.hxx:90
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:260
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1149
void UpdateScriptTypes(const ScAddress &rPos, SCCOL nColSize, SCROW nRowSize)
Definition: document10.cxx:333
void AutoFormat(sal_uInt16 nFormatNo)
Definition: viewfun2.cxx:1882
bool RemoveMerge()
Definition: viewfun2.cxx:1307
bool InsideVisibleRange(SCCOL nPosX, SCROW nPosY)
Definition: gridwin.cxx:5726
ScFormulaCell * mpFormula
Definition: cellvalue.hxx:110
SCTAB Tab() const
Definition: address.hxx:270
void SetRow(SCROW nRowP)
Definition: address.hxx:274
bool SearchAndReplace(const SvxSearchItem *pSearchItem, bool bAddUndo, bool bIsApi)
Definition: viewfun2.cxx:1900
#define SC_TAB_DELETED
Definition: uiitems.hxx:76
static OUString GetOptions(const SfxMedium &rMedium)
Definition: tablink.cxx:422
OUString GetAutoSumFormula(const ScRangeList &rRangeList, bool bSubTotal, const ScAddress &rAddr, const OpCode eCode)
Definition: viewfun2.cxx:810
ScAddress aRefVariableCell
Definition: paramisc.hxx:28
static sal_Unicode GetNativeSymbolChar(OpCode eOp)
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4766
void SetCol(SCCOL nColP)
Definition: address.hxx:278
const char * sName
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:169
TransliterationFlags
SC_DLLPUBLIC void DeletePageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
Definition: viewfun2.cxx:958
SfxItemPool & GetPool() const
static void AdjustRangesOfChartsOnDestinationPage(const ScDocument &rSrcDoc, ScDocument &rDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab)
sal_Int32 GetStartPointX() const
bool AutoFormat(const ScRange &rRange, const ScMarkData *pTabMark, sal_uInt16 nFormatNo, bool bApi)
Definition: docfunc.cxx:4200
OutputDevice * GetDevice() const
Definition: sizedev.hxx:40
bool empty() const
Definition: rangelst.hxx:88
ocSep
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1947
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_TLBR(141)
constexpr double nPPTX
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
std::optional< OUString > pStrTargetVal
Definition: paramisc.hxx:29
void SetMarkArea(const ScRange &rRange)
Definition: markdata.cxx:96
ScPasteFunc
Definition: global.hxx:189
static bool lcl_FindNextSumEntryInColumn(ScDocument &rDoc, SCCOL nCol, SCROW &nRow, SCTAB nTab, SCCOLROW &nExtend, SCROW nMinRow)
Definition: viewfun2.cxx:333
void SetTab(SCTAB nTabP)
Definition: address.hxx:282
SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: documen3.cxx:437
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1058
const editeng::SvxBorderLine * GetTop() const
static void UpdateLineAttrs(::editeng::SvxBorderLine &rLine, const ::editeng::SvxBorderLine *pDestLine, const ::editeng::SvxBorderLine *pSrcLine, bool bColor)
Definition: viewfun2.cxx:3276
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:871
T * get() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:441
bool IsChartListenerCollectionNeedsUpdate() const
Definition: document.hxx:2162
void UseScenario(const OUString &rName)
Definition: viewfun2.cxx:2325
void ShowTable(const std::vector< OUString > &rNames)
Definition: viewfun2.cxx:3157
Parameter for data table aka multiple operations.
Definition: paramisc.hxx:45
SvtScriptType
FillCmd
Definition: global.hxx:326
FontPitch GetPitch()
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:596
const SCTAB SC_TAB_APPEND
Definition: address.hxx:83
bool IsMarked() const
Definition: markdata.hxx:81
const editeng::SvxBorderLine * GetLeft() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
SvxSearchCmd GetCommand() const
ScRange getSingleRange(SCTAB nTab) const
SC_DLLPUBLIC void SetActiveScenario(SCTAB nTab, bool bActive)
Definition: documen3.cxx:882
SC_DLLPUBLIC void CreateValidTabNames(std::vector< OUString > &aNames, SCTAB nCount) const
Definition: document.cxx:439
void FillTab(const ScRange &rSrcArea, const ScMarkData &rMark, InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink)
Definition: document.cxx:3259
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:303
void SelectTable(SCTAB nTab, bool bNew)
Definition: markdata.cxx:171
void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, const OUString &rType=OUString("cell-change"), const css::uno::Sequence< css::beans::PropertyValue > &rProperties=css::uno::Sequence< css::beans::PropertyValue >())
Definition: docsh.hxx:483
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2622
sal_Int16 SCCOL
Definition: types.hxx:21
void GetAutoFormatData(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData &rData)
Definition: documen3.cxx:1200
InsertDeleteFlags
Definition: global.hxx:158
#define SC_TAB_HIDDEN
Definition: uiitems.hxx:79
static void UpdateSearchItemAddressForReplace(const SvxSearchItem &rSearchItem, SCCOL &rCol, SCROW &rRow)
Replace behaves differently to the Search; adjust the rCol and rRow accordingly.
Definition: table6.cxx:546
bool TestMergeCells()
Definition: viewfun2.cxx:1123
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:873
virtual void Clear()
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
Definition: document.cxx:392
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxInfoItemLine nLine)
const OUString & GetReplaceString() const
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
Definition: documen2.cxx:452
size_t size() const
Definition: rangelst.hxx:89
void SetCommand(SvxSearchCmd nNewCommand)
static ScAutoSum lcl_SeekAutoSumData(ScDocument &rDoc, SCCOL &nCol, SCROW &nRow, SCTAB nTab, ScDirection eDir, SCCOLROW &nExtend)
Definition: viewfun2.cxx:302
void IncRow(SCROW nDelta=1)
Definition: address.hxx:299
void SetPrintZoom(SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages)
Definition: docsh4.cxx:1637
void SetLink(SCTAB nTab, ScLinkMode nMode, const OUString &rDoc, const OUString &rFilter, const OUString &rOptions, const OUString &rTabName, sal_uLong nRefreshDelay)
Definition: documen3.cxx:546
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
SC_DLLPUBLIC bool InsertTab(SCTAB nPos, const OUString &rName, bool bExternalDocument=false, bool bUndoDeleteTab=false)
Definition: document.cxx:504
SvNumFormatType
bool GetBackward() const
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
Definition: patattr.cxx:1256
ocMax
OUString GetLinkFlt(SCTAB nTab) const
Definition: documen3.cxx:518
void SetAutoSpellData(SCCOL nPosX, SCROW nPosY, const std::vector< editeng::MisspellRanges > *pRanges)
Definition: gridwin.cxx:5707
void UseScenario(SCTAB nTab, const OUString &rName, bool bRecord=true)
Definition: docsh5.cxx:659
iterator end()
Definition: markdata.cxx:952
#define SET_LINE_ATTRIBUTES(LINE, BOXLINE)
Definition: viewfun2.cxx:3298
PaintArea
bool IsEditable() const
Definition: editable.hxx:84
bool hasNumeric() const
Definition: cellvalue.cxx:622
bool IsBlockEmpty(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes=false) const
Definition: document.cxx:5322
static ScAutoSum lcl_IsAutoSumData(ScDocument &rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, ScDirection eDir, SCCOLROW &nExtend)
Definition: viewfun2.cxx:263
bool IsAllTables() const
void GetSearchAndReplaceStart(const SvxSearchItem &rSearchItem, SCCOL &rCol, SCROW &rRow)
Definition: documen3.cxx:1214
static void UnmarkFiltered(ScMarkData &rMark, const ScDocument &rDoc)
Definition: viewutil.cxx:223
SC_DLLPUBLIC void AddPrintRange(SCTAB nTab, const ScRange &rNew)
Adds a new print ranges.
Definition: document.cxx:6335
const SCTAB MAXTAB
Definition: address.hxx:70
void RemoveManualBreaks(SCTAB nTab)
Definition: document.cxx:6253
static void notifyAllViewsHeaderInvalidation(const SfxViewShell *pForViewShell, HeaderType eHeaderType, SCTAB nCurrentTabIndex)
Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views whose current tab is equal to nCurrentTabIndex...
Definition: tabvwshc.cxx:498
ScRangeList maRanges
Definition: clipparam.hxx:34
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5594
bool TabOp(const ScRange &rRange, const ScMarkData *pTabMark, const ScTabOpParam &rParam, bool bRecord, bool bApi)
Definition: docfunc.cxx:4400
TranslateId GetMessageId() const
Definition: editable.cxx:152
const std::shared_ptr< const SfxFilter > & GetFilter() const
void PostDataChanged()
Definition: docsh3.cxx:93
SfxViewShell * GetViewShell() const
static void SetSearchLabel(const SearchLabel &rSL)
bool GetAdjacentExtendOfOuterFuncRefs(SCCOLROW &nExtend, const ScAddress &rPos, ScDirection)
Determines the extent of direct adjacent references.
Definition: token.cxx:2336
SCCOL Col() const
Definition: address.hxx:266
SC_DLLPUBLIC void SetRepeatRowRange(SCTAB nTab, std::unique_ptr< ScRange > pNew)
Definition: document.cxx:6353
static bool IsEmptyCellSearch(const SvxSearchItem &rSearchItem)
Definition: documen3.cxx:1301
void InsertAreaLink(const OUString &rFile, const OUString &rFilter, const OUString &rOptions, const OUString &rSource, const ScRange &rDestRange, sal_uLong nRefresh, bool bFitBlock, bool bApi)
Definition: docfunc.cxx:5511
void CopyAutoSpellData(FillDir eDir, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount)
Definition: viewfun2.cxx:1477
static ScDocShell * GetShellByNum(sal_uInt16 nDocNo)
Definition: docsh4.cxx:2624
virtual void ClearPageView() override
void InsertAreaLink(const OUString &rFile, const OUString &rFilter, const OUString &rOptions, const OUString &rSource)
Definition: viewfun2.cxx:2633
ScModelObj * getMustPropagateChangesModel(const ScDocShell &rDocShell)
Definition: docsh.hxx:475
bool IsError() const
Definition: tablink.cxx:578
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:468
#define SC_TABS_DELETED
Definition: uiitems.hxx:81
void SetPrintZoom(sal_uInt16 nScale)
Definition: viewfun2.cxx:999
bool UnmergeCells(const ScRange &rRange, bool bRecord, ScUndoRemoveMerge *pUndoRemoveMerge)
Definition: docfunc.cxx:5045
virtual formula::FormulaToken * AddOpCode(OpCode eCode) override
Definition: token.cxx:2264
CellType meType
Definition: cellvalue.hxx:105
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
Definition: documen3.cxx:448
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bApi)
Definition: document.cxx:4297
SC_DLLPUBLIC sal_uLong AddValidationEntry(const ScValidationData &rNew)
Definition: documen4.cxx:727
SC_DLLPUBLIC void FillAuto(FillDir eDir, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount)
Definition: viewfun2.cxx:1429
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
iterator begin()
Definition: markdata.cxx:947
sal_Int32 SCROW
Definition: types.hxx:17
void PutInOrder()
Definition: address.cxx:1582
#define SC_PF_LINES
Definition: docsh.hxx:76
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
Definition: docsh6.cxx:152
bool MergeCells(bool bApi, bool &rDoContents, bool bCenter)
Definition: viewfun2.cxx:1140
static SfxViewFrame * Current()
const editeng::SvxBorderLine * GetLine() const
SfxItemState
ocAverage
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:432
ScDrawView * GetScDrawView()
Definition: tabview.hxx:341
bool AutoSum(const ScRange &rRange, bool bSubTotal, bool bSetCursor, bool bContinue, const OpCode eCode)
Definition: viewfun2.cxx:590
#define SC_TABS_INSERTED
Definition: uiitems.hxx:80
SvBaseLink * pLink
void FindAreaPos(SCCOL &rCol, SCROW &rRow, SCTAB nTab, ScMoveDirection eDirection) const
Definition: document.cxx:6114
CellType
Definition: global.hxx:281
SCTAB MakeScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags, ScMarkData &rMark, bool bRecord=true)
Definition: docsh5.cxx:784
OUString aName
field button for datapilot
void SetWhich(sal_uInt16 nId)
SCTAB GetFirstSelected() const
Definition: markdata.cxx:199
sal_uLong GetLinkRefreshDelay(SCTAB nTab) const
Definition: documen3.cxx:539
const OUString & GetSearchString() const
sal_Int32 GetStartPointY() const
RET_OK
const ScSheetEvents * GetSheetEvents(SCTAB nTab) const
Definition: documen3.cxx:659
SCTAB GetLastSelected() const
Definition: markdata.cxx:208
bool SetTabBgColor(const Color &rColor, SCTAB nTabNr)
Definition: viewfun2.cxx:2613
void EnterAutoSum(const ScRangeList &rRangeList, bool bSubTotal, const ScAddress &rAddr, const OpCode eCode)
Definition: viewfun2.cxx:584
static bool lcl_FindNextSumEntryInRow(ScDocument &rDoc, SCCOL &nCol, SCROW nRow, SCTAB nTab, SCCOLROW &nExtend, SCCOL nMinCol)
Definition: viewfun2.cxx:348
bool IsInVBAMode() const
Definition: document.cxx:6517
SC_DLLPUBLIC bool HasData(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: documen5.cxx:524
virtual short run()
SC_DLLPUBLIC void FillSimple(FillDir eDir)
Definition: viewfun2.cxx:1357
void * p
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
SC_DLLPUBLIC OUString GetLinkTab(SCTAB nTab) const
Definition: documen3.cxx:532
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
const char * pChar
bool IsAutoSpell() const
Definition: docoptio.hxx:53
bool TabKeyInput(const KeyEvent &rKEvt)
Definition: tabvwsh4.cxx:1175
SC_DLLPUBLIC void UpdateChartListenerCollection()
Definition: documen5.cxx:568
SC_DLLPUBLIC void SetPrintEntireSheet(SCTAB nTab)
Marks the specified sheet to be printed completely.
Definition: document.cxx:6341
SC_DLLPUBLIC bool DeleteTab(SCTAB nTab)
Definition: document.cxx:673
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:447
void NotifyIfChangesListeners(const ScDocShell &rDocShell, const ScRange &rRange, const OUString &rType=OUString("cell-change"))
Definition: docsh.hxx:491
SvxSearchCmd
void ShowChildWindow(sal_uInt16, bool bVisible=true)
bool DeleteTables(const std::vector< SCTAB > &TheTabs, bool bRecord=true)
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:986
void ImportTables(ScDocShell *pSrcShell, SCTAB nCount, const SCTAB *pSrcTabs, bool bLink, SCTAB nTab)
Definition: viewfun2.cxx:2680
Complex reference (a range) into the sheet.
Definition: refdata.hxx:122
bool SearchAndReplace(const SvxSearchItem &rSearchItem, SCCOL &rCol, SCROW &rRow, SCTAB &rTab, const ScMarkData &rMark, ScRangeList &rMatchedRanges, OUString &rUndoStr, ScDocument *pUndoDoc=nullptr)
Definition: documen3.cxx:1308
sal_uInt32 GetValue() const
ScAddress aRefFormulaCell
Definition: paramisc.hxx:27
bool MoveTable(SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord)
Definition: docsh5.cxx:901
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
Definition: document.cxx:908
bool IsUndoEnabled() const
Definition: document.hxx:1535
ScDirection
Definition: global.hxx:352
const OUString & GetCodeName() const
Definition: document.hxx:596
void GetMultiMarkArea(ScRange &rRange) const
Definition: markdata.cxx:116
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:222
bool NeedsObject() const
Definition: editutil.hxx:102
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2594
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, bool bApi)
Definition: viewfun2.cxx:192
void InsertSpecialChar(const OUString &rStr, const vcl::Font &rFont)
Definition: viewfun2.cxx:3242
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:183
bool TestRemoveMerge()
Definition: viewfun2.cxx:1268
std::map< OUString, OUString > aParameters
bool HasStartPoint() const
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
Definition: clipparam.hxx:30
SC_DLLPUBLIC void ExtendOverlapped(SCCOL &rStartCol, SCROW &rStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:5504
ScAutoFormatData * CreateAutoFormatData()
Definition: viewfun2.cxx:1861
void FillCrossDblClick()
Downward fill of selected cell(s) by double-clicking cross-hair cursor.
Definition: viewfun2.cxx:1718
void ExtendScenario()
Definition: viewfun2.cxx:2307
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:218
std::set< SCTAB > MarkedTabsType
Definition: markdata.hxx:45
void VBA_DeleteModule(ScDocShell &rDocSh, const OUString &sModuleName)
Definition: docfunc.cxx:3233
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:213
double GetPPTX() const
Definition: sizedev.hxx:41
ocClose
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_BLTR(142)
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
::std::vector< ScUndoTabColorInfo > List
Definition: tabbgcolor.hxx:36
SC_DLLPUBLIC void GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab, CellType &rCellType) const
Definition: document.cxx:3778
void HideTable(const ScMarkData &rMark, SCTAB nTabToSelect=-1)
Definition: viewfun2.cxx:3192
rtl_TextEncoding GetCharSet() const
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:22
ScAutoSum
Definition: viewfun2.cxx:250
sc::MultiDataCellState HasMultipleDataCells(const ScRange &rRange) const
Check if the specified range contains either: 1) one non-empty cell, 2) more than one non-empty cells...
Definition: document10.cxx:41
void AdjustPrintZoom()
Definition: viewfun2.cxx:1006
void MakeScenario(const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: viewfun2.cxx:2286
FormulaToken * AddDouble(double fVal)
void TabOp(const ScTabOpParam &rParam, bool bRecord=true)
Definition: viewfun2.cxx:2273
ocSum
static SC_DLLPUBLIC const SvxSearchItem & GetSearchItem()
Definition: global.cxx:215
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1923
SfxMedium * GetMedium() const