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