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 <vcl/waitobj.hxx>
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, MAXCOLCOUNT, nEndNo-nStartNo+1);
159  if (rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab))
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 )
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);
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(*pDoc, 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* pDoc, 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  pDoc, 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* pDoc, 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( pDoc, 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* pDoc, 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( pDoc, 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* pDoc, 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( pDoc, 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( pDoc, 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( pDoc, 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* pDoc, 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( pDoc, 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( pDoc, 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( pDoc, 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* pDoc = 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( pDoc, nCol, nRow-1, nTab,
499  DIR_TOP, nExtend /*out*/ )) == ScAutoSumData )
500  && ((eSum = lcl_IsAutoSumData( pDoc, 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( pDoc, 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( pDoc, nCol, nSeekRow, nTab, DIR_TOP, nExtend /*out*/ )) != ScAutoSumNone )
514  bRow = true;
515  else if (( eSum = lcl_SeekAutoSumData( pDoc, 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( pDoc, nCol,
544  nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ ) == eSum )
545  --nStartRow;
546  }
547  else
548  {
549  while ( nStartCol != 0 && lcl_IsAutoSumData( pDoc, 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( pDoc, 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( pDoc, 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* pDoc = 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( pDoc, 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( pDoc, 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 = pDoc->IsBlockEmpty( nTab, nStartCol, nEndRow, nEndCol, nEndRow );
646  const bool bEndColEmpty = pDoc->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 < pDoc->MaxRow() )
655  {
656  ++nInsRow;
657  while ( !pDoc->IsBlockEmpty( nTab, nStartCol, nInsRow, nEndCol, nInsRow ) )
658  {
659  if ( nInsRow < pDoc->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 < pDoc->MaxCol() )
681  {
682  ++nInsCol;
683  while ( !pDoc->IsBlockEmpty( nTab, nInsCol, nStartRow, nInsCol, nEndRow ) )
684  {
685  if ( nInsCol < pDoc->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 ( !pDoc->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( pDoc, 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 ( !pDoc->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( pDoc, 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* pDoc = rViewData.GetDocument();
813  std::unique_ptr<ScTokenArray> pArray(new ScTokenArray(pDoc));
814 
815  pArray->AddOpCode(bSubTotal ? ocSubTotal : eCode);
816  pArray->AddOpCode(ocOpen);
817 
818  if (bSubTotal)
819  {
820  pArray->AddDouble( GetSubTotal( eCode ) );
821  pArray->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  pArray->AddOpCode(ocSep);
833  ScComplexRefData aRef;
834  aRef.InitRangeRel(pDoc, r, rAddr);
835  pArray->AddDoubleReference(aRef);
836  }
837  }
838 
839  pArray->AddOpCode(ocClose);
840 
841  ScCompiler aComp(pDoc, rAddr, *pArray, pDoc->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* pDoc = GetViewData().GetDocument();
881  OUString aNewStr = rString;
882  if ( pData )
883  {
884  const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
885  ScTabEditEngine aEngine( *pOldPattern, pDoc->GetEnginePool(), pDoc );
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 
898  WaitObject aWait( GetFrameWin() );
899 
900  ScAddress aPos( nCol, nRow, nTab );
901 
903  pInsDoc->ResetClip( pDoc, nTab );
904 
905  if (aNewStr[0] == '=') // Formula ?
906  {
907  // SetString not possible, because in Clipboard-Documents nothing will be compiled!
908  pInsDoc->SetFormulaCell(aPos, new ScFormulaCell(pDoc, aPos, aNewStr));
909  }
910  else if ( pData )
911  {
912  // A copy of pData will be stored.
913  pInsDoc->SetEditText(aPos, *pData, pDoc->GetEditPool());
914  }
915  else
916  pInsDoc->SetString( nCol, nRow, nTab, aNewStr );
917 
918  pInsDoc->SetClipArea( ScRange(aPos) );
919  // insert Block, with Undo etc.
920  if ( PasteFromClip( InsertDeleteFlags::CONTENTS, pInsDoc.get(), ScPasteFunc::NONE, false, false,
922  {
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  std::unique_ptr<ScPatternAttr> pPattern(new ScPatternAttr( pDoc->GetPool() ));
931  pPattern->GetItemSet().Put( *pItem );
932  SvNumFormatType nNewType = pDoc->GetFormatTable()->GetType( pItem->GetValue() );
933  pDoc->ApplyPatternIfNumberformatIncompatible( aRange, rMark,
934  *pPattern, nNewType );
935  }
936  }
937 }
938 
939 // manual page break
940 
941 void ScViewFunc::InsertPageBreak( bool bColumn, bool bRecord, const ScAddress* pPos,
942  bool bSetModified )
943 {
944  SCTAB nTab = GetViewData().GetTabNo();
945  ScAddress aCursor;
946  if (pPos)
947  aCursor = *pPos;
948  else
949  aCursor = ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), nTab );
950 
951  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
952  InsertPageBreak( bColumn, aCursor, bRecord, bSetModified );
953 
954  if ( bSuccess && bSetModified )
955  UpdatePageBreakData( true ); // for PageBreak-Mode
956 }
957 
958 void ScViewFunc::DeletePageBreak( bool bColumn, bool bRecord, const ScAddress* pPos,
959  bool bSetModified )
960 {
961  SCTAB nTab = GetViewData().GetTabNo();
962  ScAddress aCursor;
963  if (pPos)
964  aCursor = *pPos;
965  else
966  aCursor = ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), nTab );
967 
968  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
969  RemovePageBreak( bColumn, aCursor, bRecord, bSetModified );
970 
971  if ( bSuccess && bSetModified )
972  UpdatePageBreakData( true ); // for PageBreak-Mode
973 }
974 
976 {
977  ScDocShell* pDocSh = GetViewData().GetDocShell();
978  ScDocument& rDoc = pDocSh->GetDocument();
979  SCTAB nTab = GetViewData().GetTabNo();
980  bool bUndo(rDoc.IsUndoEnabled());
981 
982  if (bUndo)
983  {
985  pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true );
986  rDoc.CopyToDocument( 0,0,nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab, InsertDeleteFlags::NONE, false, *pUndoDoc );
987  pDocSh->GetUndoManager()->AddUndoAction(
988  std::make_unique<ScUndoRemoveBreaks>( pDocSh, nTab, std::move(pUndoDoc) ) );
989  }
990 
991  rDoc.RemoveManualBreaks(nTab);
992  rDoc.UpdatePageBreaks(nTab);
993 
994  UpdatePageBreakData( true );
995  pDocSh->SetDocumentModified();
996  pDocSh->PostPaint( 0,0,nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab, PaintPartFlags::Grid );
997 }
998 
999 void ScViewFunc::SetPrintZoom(sal_uInt16 nScale)
1000 {
1001  ScDocShell* pDocSh = GetViewData().GetDocShell();
1002  SCTAB nTab = GetViewData().GetTabNo();
1003  pDocSh->SetPrintZoom( nTab, nScale, 0/*nPages*/ );
1004 }
1005 
1007 {
1008  ScRange aRange;
1009  if ( GetViewData().GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
1010  GetViewData().GetMarkData().GetMultiMarkArea( aRange );
1011  GetViewData().GetDocShell()->AdjustPrintZoom( aRange );
1012 }
1013 
1014 void ScViewFunc::SetPrintRanges( bool bEntireSheet, const OUString* pPrint,
1015  const OUString* pRepCol, const OUString* pRepRow,
1016  bool bAddPrint )
1017 {
1018  // on all selected tables
1019 
1020  ScDocShell* pDocSh = GetViewData().GetDocShell();
1021  ScDocument& rDoc = pDocSh->GetDocument();
1022  ScMarkData& rMark = GetViewData().GetMarkData();
1023  bool bUndo (rDoc.IsUndoEnabled());
1024 
1025  std::unique_ptr<ScPrintRangeSaver> pOldRanges = rDoc.CreatePrintRangeSaver();
1026 
1027  ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
1028 
1029  for (const SCTAB& nTab : rMark)
1030  {
1031  ScRange aRange( 0,0,nTab );
1032 
1033  // print ranges
1034 
1035  if( !bAddPrint )
1036  rDoc.ClearPrintRanges( nTab );
1037 
1038  if( bEntireSheet )
1039  {
1040  rDoc.SetPrintEntireSheet( nTab );
1041  }
1042  else if ( pPrint )
1043  {
1044  if ( !pPrint->isEmpty() )
1045  {
1047  sal_Int32 nPos = 0;
1048  do
1049  {
1050  const OUString aToken = pPrint->getToken(0, sep, nPos);
1051  if ( aRange.ParseAny( aToken, &rDoc, aDetails ) & ScRefFlags::VALID )
1052  rDoc.AddPrintRange( nTab, aRange );
1053  }
1054  while (nPos >= 0);
1055  }
1056  }
1057  else // NULL = use selection (print range is always set), use empty string to delete all ranges
1058  {
1059  if ( GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
1060  {
1061  rDoc.AddPrintRange( nTab, aRange );
1062  }
1063  else if ( rMark.IsMultiMarked() )
1064  {
1065  rMark.MarkToMulti();
1066  ScRangeListRef pList( new ScRangeList );
1067  rMark.FillRangeListWithMarks( pList.get(), false );
1068  for (size_t i = 0, n = pList->size(); i < n; ++i)
1069  {
1070  const ScRange & rR = (*pList)[i];
1071  rDoc.AddPrintRange(nTab, rR);
1072  }
1073  }
1074  }
1075 
1076  // repeat columns
1077 
1078  if ( pRepCol )
1079  {
1080  if ( pRepCol->isEmpty() )
1081  rDoc.SetRepeatColRange( nTab, nullptr );
1082  else
1083  if ( aRange.ParseAny( *pRepCol, &rDoc, aDetails ) & ScRefFlags::VALID )
1084  rDoc.SetRepeatColRange( nTab, std::unique_ptr<ScRange>(new ScRange(aRange)) );
1085  }
1086 
1087  // repeat rows
1088 
1089  if ( pRepRow )
1090  {
1091  if ( pRepRow->isEmpty() )
1092  rDoc.SetRepeatRowRange( nTab, nullptr );
1093  else
1094  if ( aRange.ParseAny( *pRepRow, &rDoc, aDetails ) & ScRefFlags::VALID )
1095  rDoc.SetRepeatRowRange( nTab, std::unique_ptr<ScRange>(new ScRange(aRange)) );
1096  }
1097  }
1098 
1099  // undo (for all tables)
1100  if (bUndo)
1101  {
1102  SCTAB nCurTab = GetViewData().GetTabNo();
1103  std::unique_ptr<ScPrintRangeSaver> pNewRanges = rDoc.CreatePrintRangeSaver();
1104  pDocSh->GetUndoManager()->AddUndoAction(
1105  std::make_unique<ScUndoPrintRange>( pDocSh, nCurTab, std::move(pOldRanges), std::move(pNewRanges) ) );
1106  }
1107  else
1108  pOldRanges.reset();
1109 
1110  // update page breaks
1111 
1112  for (const auto& rTab : rMark)
1113  ScPrintFunc( pDocSh, pDocSh->GetPrinter(), rTab ).UpdatePages();
1114 
1115  SfxBindings& rBindings = GetViewData().GetBindings();
1116  rBindings.Invalidate( SID_DELETE_PRINTAREA );
1117 
1118  pDocSh->SetDocumentModified();
1119 }
1120 
1121 // Merge cells
1122 
1123 bool ScViewFunc::TestMergeCells() // pre-test (for menu)
1124 {
1125  // simple test: true if there's a selection but no multi selection and not filtered
1126 
1127  const ScMarkData& rMark = GetViewData().GetMarkData();
1128  if ( rMark.IsMarked() || rMark.IsMultiMarked() )
1129  {
1130  ScRange aRange;
1131  bool bMergable = ( GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE );
1132  bMergable = bMergable && ( aRange.aStart.Col() != aRange.aEnd.Col() ||
1133  aRange.aStart.Row() != aRange.aEnd.Row() );
1134  return bMergable;
1135  }
1136  else
1137  return false;
1138 }
1139 
1140 bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
1141 {
1142  // Editable- and Being-Nested- test must be at the beginning (in DocFunc too),
1143  // so that the Contents-QueryBox won't appear
1144  ScEditableTester aTester( this );
1145  if (!aTester.IsEditable())
1146  {
1147  ErrorMessage(aTester.GetMessageId());
1148  return false;
1149  }
1150 
1151  ScMarkData& rMark = GetViewData().GetMarkData();
1152  rMark.MarkToSimple();
1153  if (!rMark.IsMarked())
1154  {
1155  ErrorMessage(STR_NOMULTISELECT);
1156  return false;
1157  }
1158 
1159  ScDocShell* pDocSh = GetViewData().GetDocShell();
1160  ScDocument& rDoc = pDocSh->GetDocument();
1161 
1162  ScRange aMarkRange;
1163  rMark.GetMarkArea( aMarkRange );
1164  SCCOL nStartCol = aMarkRange.aStart.Col();
1165  SCROW nStartRow = aMarkRange.aStart.Row();
1166  SCTAB nStartTab = aMarkRange.aStart.Tab();
1167  SCCOL nEndCol = aMarkRange.aEnd.Col();
1168  SCROW nEndRow = aMarkRange.aEnd.Row();
1169  SCTAB nEndTab = aMarkRange.aEnd.Tab();
1170  if ( nStartCol == nEndCol && nStartRow == nEndRow )
1171  {
1172  // nothing to do
1173  return true;
1174  }
1175 
1176  if ( rDoc.HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
1178  { // "Don't nest merging !"
1179  ErrorMessage(STR_MSSG_MERGECELLS_0);
1180  return false;
1181  }
1182 
1183  // Check for the contents of all selected tables.
1184  bool bAskDialog = false;
1185  ScCellMergeOption aMergeOption(nStartCol, nStartRow, nEndCol, nEndRow, bCenter);
1186  for (const SCTAB& i : rMark)
1187  {
1188  aMergeOption.maTabs.insert(i);
1189 
1190  sc::MultiDataCellState aState = rDoc.HasMultipleDataCells(aMergeOption.getSingleRange(i));
1191  switch (aState.meState)
1192  {
1194  {
1195  // this range contains multiple data cells.
1196  bAskDialog = true;
1197  break;
1198  }
1200  {
1201  // this range contains only one data cell.
1202  if (nStartCol != aState.mnCol1 || nStartRow != aState.mnRow1)
1203  rDoContents = true; // move the value to the top-left.
1204  break;
1205  }
1206  default:
1207  ;
1208  }
1209  }
1210 
1211  bool bOk = true;
1212  bool bEmptyMergedCells = officecfg::Office::Calc::Compatibility::MergeCells::EmptyMergedCells::get();
1213 
1214  if (bAskDialog)
1215  {
1216  bool bShowDialog = officecfg::Office::Calc::Compatibility::MergeCells::ShowDialog::get();
1217  if (!bApi && bShowDialog)
1218  {
1219  ScMergeCellsDialog aBox(GetViewData().GetDialogParent());
1220  sal_uInt16 nRetVal = aBox.run();
1221 
1222  if ( nRetVal == RET_OK )
1223  {
1224  switch (aBox.GetMergeCellsOption())
1225  {
1227  rDoContents = true;
1228  break;
1230  bEmptyMergedCells = false;
1231  break;
1233  bEmptyMergedCells = true;
1234  break;
1235  default:
1236  assert(!"Unknown option for merge cells.");
1237  break;
1238  }
1239  }
1240  else if ( nRetVal == RET_CANCEL )
1241  bOk = false;
1242  }
1243  }
1244 
1245  if (bOk)
1246  {
1247  bOk = pDocSh->GetDocFunc().MergeCells( aMergeOption, rDoContents, true/*bRecord*/, bApi, bEmptyMergedCells );
1248 
1249  if (bOk)
1250  {
1251  SetCursor( nStartCol, nStartRow );
1252  //DoneBlockMode( sal_False);
1253  Unmark();
1254 
1255  pDocSh->UpdateOle(&GetViewData());
1256  UpdateInputLine();
1257 
1258  OUString aStartAddress = aMarkRange.aStart.GetColRowString();
1259  OUString aEndAddress = aMarkRange.aEnd.GetColRowString();
1260 
1261  collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "MERGE_CELLS");
1262  }
1263  }
1264 
1265  return bOk;
1266 }
1267 
1269 {
1270  bool bMerged = false;
1271  ScRange aRange;
1272  if (GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE)
1273  {
1274  ScDocument* pDoc = GetViewData().GetDocument();
1275  if ( pDoc->HasAttrib( aRange, HasAttrFlags::Merged ) )
1276  bMerged = true;
1277  }
1278  return bMerged;
1279 }
1280 
1281 static bool lcl_extendMergeRange(ScCellMergeOption& rOption, const ScRange& rRange)
1282 {
1283  bool bExtended = false;
1284  if (rOption.mnStartCol > rRange.aStart.Col())
1285  {
1286  rOption.mnStartCol = rRange.aStart.Col();
1287  bExtended = true;
1288  }
1289  if (rOption.mnStartRow > rRange.aStart.Row())
1290  {
1291  rOption.mnStartRow = rRange.aStart.Row();
1292  bExtended = true;
1293  }
1294  if (rOption.mnEndCol < rRange.aEnd.Col())
1295  {
1296  rOption.mnEndCol = rRange.aEnd.Col();
1297  bExtended = true;
1298  }
1299  if (rOption.mnEndRow < rRange.aEnd.Row())
1300  {
1301  rOption.mnEndRow = rRange.aEnd.Row();
1302  bExtended = true;
1303  }
1304  return bExtended;
1305 }
1306 
1308 {
1309  ScRange aRange;
1310  ScEditableTester aTester( this );
1311  if (!aTester.IsEditable())
1312  {
1313  ErrorMessage(aTester.GetMessageId());
1314  return false;
1315  }
1316  else if (GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE)
1317  {
1318  ScDocument* pDoc = GetViewData().GetDocument();
1319  ScRange aExtended( aRange );
1320  pDoc->ExtendMerge( aExtended );
1321  ScDocShell* pDocSh = GetViewData().GetDocShell();
1322  const ScMarkData& rMark = GetViewData().GetMarkData();
1323  ScCellMergeOption aOption(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row());
1324  bool bExtended = false;
1325  do
1326  {
1327  bExtended = false;
1328  for (const SCTAB& i : rMark)
1329  {
1330  aOption.maTabs.insert(i);
1331  aExtended.aStart.SetTab(i);
1332  aExtended.aEnd.SetTab(i);
1333  pDoc->ExtendMerge(aExtended);
1334  pDoc->ExtendOverlapped(aExtended);
1335 
1336  // Expand the current range to be inclusive of all merged
1337  // areas on all sheets.
1338  bExtended = lcl_extendMergeRange(aOption, aExtended);
1339  }
1340  }
1341  while (bExtended);
1342 
1343  bool bOk = pDocSh->GetDocFunc().UnmergeCells(aOption, true/*bRecord*/, nullptr);
1344  aExtended = aOption.getFirstSingleRange();
1345  MarkRange( aExtended );
1346 
1347  if (bOk)
1348  pDocSh->UpdateOle(&GetViewData());
1349  }
1350 
1351  OUString aCellLocation = aRange.aStart.GetColRowString();
1352  collectUIInformation({{"CELL", aCellLocation}}, "UNMERGE_CELL");
1353 
1354  return true;
1355 }
1356 
1358 {
1359  ScRange aRange;
1360  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1361  {
1362  ScDocShell* pDocSh = GetViewData().GetDocShell();
1363  const ScMarkData& rMark = GetViewData().GetMarkData();
1364  bool bSuccess = pDocSh->GetDocFunc().FillSimple( aRange, &rMark, eDir, false );
1365  if (bSuccess)
1366  {
1367  pDocSh->UpdateOle(&GetViewData());
1368  UpdateScrollBars();
1369 
1370  auto& rDoc = pDocSh->GetDocument();
1371  bool bDoAutoSpell = rDoc.GetDocOptions().IsAutoSpell();
1372  if ( bDoAutoSpell )
1373  {
1374  // Copy AutoSpellData from above(left/right/below) if no selection.
1375  switch (eDir)
1376  {
1377  case FILL_TO_BOTTOM:
1378  if (aRange.aStart.Row() > 0 && aRange.aStart.Row() == aRange.aEnd.Row())
1379  aRange.aStart.IncRow(-1);
1380  break;
1381  case FILL_TO_TOP:
1382  if (aRange.aEnd.Row() < rDoc.MaxRow() && aRange.aStart.Row() == aRange.aEnd.Row())
1383  aRange.aEnd.IncRow(1);
1384  break;
1385  case FILL_TO_RIGHT:
1386  if (aRange.aStart.Col() > 0 && aRange.aStart.Col() == aRange.aEnd.Col())
1387  aRange.aStart.IncCol(-1);
1388  break;
1389  case FILL_TO_LEFT:
1390  if (aRange.aEnd.Col() < rDoc.MaxCol() && aRange.aStart.Col() == aRange.aEnd.Col())
1391  aRange.aEnd.IncCol(1);
1392  break;
1393  }
1394  CopyAutoSpellData(eDir, aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(),
1395  ::std::numeric_limits<sal_uLong>::max());
1396  }
1397 
1398  // Invalidate cell slots and update input line with new content.
1399  CellContentChanged();
1400  }
1401  }
1402  else
1403  ErrorMessage(STR_NOMULTISELECT);
1404 }
1405 
1407  double fStart, double fStep, double fMax )
1408 {
1409  ScRange aRange;
1410  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1411  {
1412  ScDocShell* pDocSh = GetViewData().GetDocShell();
1413  const ScMarkData& rMark = GetViewData().GetMarkData();
1414  bool bSuccess = pDocSh->GetDocFunc().
1415  FillSeries( aRange, &rMark, eDir, eCmd, eDateCmd,
1416  fStart, fStep, fMax, false );
1417  if (bSuccess)
1418  {
1419  pDocSh->UpdateOle(&GetViewData());
1420  UpdateScrollBars();
1421 
1423  }
1424  }
1425  else
1426  ErrorMessage(STR_NOMULTISELECT);
1427 }
1428 
1429 void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
1430  SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount )
1431 {
1432  SCTAB nTab = GetViewData().GetTabNo();
1433  ScRange aRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab );
1434  ScRange aSourceRange( aRange );
1435  ScDocShell* pDocSh = GetViewData().GetDocShell();
1436  const ScMarkData& rMark = GetViewData().GetMarkData();
1437  bool bSuccess = pDocSh->GetDocFunc().
1438  FillAuto( aRange, &rMark, eDir, nCount, false );
1439  if (bSuccess)
1440  {
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  {
1451  ScRangeList aChangeRanges;
1452  ScRange aChangeRange( aRange );
1453  switch (eDir)
1454  {
1455  case FILL_TO_BOTTOM:
1456  aChangeRange.aStart.SetRow( aSourceRange.aEnd.Row() + 1 );
1457  break;
1458  case FILL_TO_TOP:
1459  aChangeRange.aEnd.SetRow( aSourceRange.aStart.Row() - 1 );
1460  break;
1461  case FILL_TO_RIGHT:
1462  aChangeRange.aStart.SetCol( aSourceRange.aEnd.Col() + 1 );
1463  break;
1464  case FILL_TO_LEFT:
1465  aChangeRange.aEnd.SetCol( aSourceRange.aStart.Col() - 1 );
1466  break;
1467  default:
1468  break;
1469  }
1470  aChangeRanges.push_back( aChangeRange );
1471  HelperNotifyChanges::Notify(*pModelObj, aChangeRanges);
1472  }
1473  }
1474 }
1475 
1476 void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
1477  SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount )
1478 {
1479  ScGridWindow* pWin = GetActiveWin();
1480  if ( pWin->InsideVisibleRange(nStartCol, nStartRow) && pWin->InsideVisibleRange(nEndCol, nEndRow) )
1481  {
1482  if ( nCount == ::std::numeric_limits<sal_uLong>::max() )
1483  {
1484  switch( eDir )
1485  {
1486  case FILL_TO_BOTTOM:
1487  for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
1488  {
1489  const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nColItr, nStartRow);
1490  if ( !pRanges )
1491  continue;
1492  for ( SCROW nRowItr = nStartRow + 1; nRowItr <= nEndRow; ++nRowItr )
1493  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1494  }
1495  break;
1496  case FILL_TO_TOP:
1497  for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
1498  {
1499  const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nColItr, nEndRow);
1500  if ( !pRanges )
1501  continue;
1502  for ( SCROW nRowItr = nEndRow - 1; nRowItr >= nStartRow; --nRowItr )
1503  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1504  }
1505  break;
1506  case FILL_TO_RIGHT:
1507  for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
1508  {
1509  const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nStartCol, nRowItr);
1510  if ( !pRanges )
1511  continue;
1512  for ( SCCOL nColItr = nStartCol + 1; nColItr <= nEndCol; ++nColItr )
1513  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1514  }
1515  break;
1516  case FILL_TO_LEFT:
1517  for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
1518  {
1519  const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nEndCol, nRowItr);
1520  if ( !pRanges )
1521  continue;
1522  for ( SCCOL nColItr = nEndCol - 1; nColItr >= nStartCol; --nColItr )
1523  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1524  }
1525  break;
1526  }
1527  return;
1528  }
1529 
1530  typedef const std::vector<editeng::MisspellRanges>* MisspellRangesType;
1531  SCROW nRowRepeatSize = nEndRow - nStartRow + 1;
1532  SCCOL nColRepeatSize = nEndCol - nStartCol + 1;
1533  SCROW nTillRow = 0;
1534  SCCOL nTillCol = 0;
1535  std::vector<std::vector<MisspellRangesType>> aSourceSpellRanges(nRowRepeatSize, std::vector<MisspellRangesType>(nColRepeatSize));
1536 
1537  for ( SCROW nRowIdx = 0; nRowIdx < nRowRepeatSize; ++nRowIdx )
1538  for ( SCCOL nColIdx = 0; nColIdx < nColRepeatSize; ++nColIdx )
1539  aSourceSpellRanges[nRowIdx][nColIdx] = pWin->GetAutoSpellData( nStartCol + nColIdx, nStartRow + nRowIdx );
1540 
1541  switch( eDir )
1542  {
1543  case FILL_TO_BOTTOM:
1544  nTillRow = nEndRow + nCount;
1545  for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
1546  {
1547  for ( SCROW nRowItr = nEndRow + 1; nRowItr <= nTillRow; ++nRowItr )
1548  {
1549  size_t nSourceRowIdx = ( nRowItr - nEndRow - 1 ) % nRowRepeatSize;
1550  MisspellRangesType pRanges = aSourceSpellRanges[nSourceRowIdx][nColItr - nStartCol];
1551  if ( !pRanges )
1552  continue;
1553  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1554  }
1555  }
1556  break;
1557 
1558  case FILL_TO_TOP:
1559  nTillRow = nStartRow - nCount;
1560  for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
1561  {
1562  for ( SCROW nRowItr = nStartRow - 1; nRowItr >= nTillRow; --nRowItr )
1563  {
1564  size_t nSourceRowIdx = nRowRepeatSize - 1 - ( ( nStartRow - 1 - nRowItr ) % nRowRepeatSize );
1565  MisspellRangesType pRanges = aSourceSpellRanges[nSourceRowIdx][nColItr - nStartCol];
1566  if ( !pRanges )
1567  continue;
1568  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1569  }
1570  }
1571  break;
1572 
1573  case FILL_TO_RIGHT:
1574  nTillCol = nEndCol + nCount;
1575  for ( SCCOL nColItr = nEndCol + 1; nColItr <= nTillCol; ++nColItr )
1576  {
1577  size_t nSourceColIdx = ( nColItr - nEndCol - 1 ) % nColRepeatSize;
1578  for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
1579  {
1580  MisspellRangesType pRanges = aSourceSpellRanges[nRowItr - nStartRow][nSourceColIdx];
1581  if ( !pRanges )
1582  continue;
1583  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1584  }
1585  }
1586  break;
1587 
1588  case FILL_TO_LEFT:
1589  nTillCol = nStartCol - nCount;
1590  for ( SCCOL nColItr = nStartCol - 1; nColItr >= nTillCol; --nColItr )
1591  {
1592  size_t nSourceColIdx = nColRepeatSize - 1 - ( ( nStartCol - 1 - nColItr ) % nColRepeatSize );
1593  for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
1594  {
1595  MisspellRangesType pRanges = aSourceSpellRanges[nRowItr - nStartRow][nSourceColIdx];
1596  if ( !pRanges )
1597  continue;
1598  pWin->SetAutoSpellData(nColItr, nRowItr, pRanges);
1599  }
1600  }
1601  break;
1602  }
1603  }
1604  else
1605  pWin->ResetAutoSpell();
1606 
1607 }
1608 
1609 void ScViewFunc::FillTab( InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink )
1610 {
1612  ScEditableTester aTester( this );
1613  if (!aTester.IsEditable())
1614  {
1615  ErrorMessage(aTester.GetMessageId());
1616  return;
1617  }
1618 
1619  ScDocShell* pDocSh = GetViewData().GetDocShell();
1620  ScDocument& rDoc = pDocSh->GetDocument();
1621  ScMarkData& rMark = GetViewData().GetMarkData();
1622  SCTAB nTab = GetViewData().GetTabNo();
1623  bool bUndo(rDoc.IsUndoEnabled());
1624 
1625  ScRange aMarkRange;
1626  rMark.MarkToSimple();
1627  bool bMulti = rMark.IsMultiMarked();
1628  if (bMulti)
1629  rMark.GetMultiMarkArea( aMarkRange );
1630  else if (rMark.IsMarked())
1631  rMark.GetMarkArea( aMarkRange );
1632  else
1633  aMarkRange = ScRange( GetViewData().GetCurX(), GetViewData().GetCurY(), nTab );
1634 
1635  ScDocumentUniquePtr pUndoDoc;
1636 
1637  if (bUndo)
1638  {
1639  pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
1640  pUndoDoc->InitUndo( &rDoc, nTab, nTab );
1641 
1642  for (const SCTAB& i : rMark)
1643  if (i != nTab )
1644  {
1645  pUndoDoc->AddUndoTab( i, i );
1646  aMarkRange.aStart.SetTab( i );
1647  aMarkRange.aEnd.SetTab( i );
1648  rDoc.CopyToDocument( aMarkRange, InsertDeleteFlags::ALL, bMulti, *pUndoDoc );
1649  }
1650  }
1651 
1652  if (bMulti)
1653  rDoc.FillTabMarked( nTab, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
1654  else
1655  {
1656  aMarkRange.aStart.SetTab( nTab );
1657  aMarkRange.aEnd.SetTab( nTab );
1658  rDoc.FillTab( aMarkRange, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
1659  }
1660 
1661  if (bUndo)
1662  {
1663  pDocSh->GetUndoManager()->AddUndoAction(
1664  std::make_unique<ScUndoFillTable>( pDocSh, rMark,
1665  aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nTab,
1666  aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), nTab,
1667  std::move(pUndoDoc), bMulti, nTab, nFlags, nFunction, bSkipEmpty, bAsLink ) );
1668  }
1669 
1670  pDocSh->PostPaintGridAll();
1671  pDocSh->PostDataChanged();
1672 }
1673 
1690 {
1691  ScRange aRange;
1692  GetViewData().GetSimpleArea( aRange );
1693  aRange.PutInOrder();
1694 
1695  SCTAB nTab = GetViewData().GetCurPos().Tab();
1696  SCCOL nStartX = aRange.aStart.Col();
1697  SCROW nStartY = aRange.aStart.Row();
1698  SCCOL nEndX = aRange.aEnd.Col();
1699  SCROW nEndY = aRange.aEnd.Row();
1700 
1701  ScDocument* pDoc = GetViewData().GetDocument();
1702 
1703  if (nEndY >= pDoc->MaxRow())
1704  // Nothing to fill.
1705  return;
1706 
1707  // Make sure the selection is not empty
1708  if ( pDoc->IsBlockEmpty( nTab, nStartX, nStartY, nEndX, nEndY ) )
1709  return;
1710 
1711  // If there is data in all columns immediately below the selection then
1712  // switch to overwriting fill.
1713  SCROW nOverWriteEndRow = pDoc->MaxRow();
1714  for (SCCOL nCol = nStartX; nCol <= nEndX; ++nCol)
1715  {
1716  if (pDoc->HasData( nCol, nEndY + 1, nTab))
1717  {
1718  // Determine the shortest data column to end the fill.
1719  SCROW nY = nEndY + 1;
1720  // FindAreaPos() returns the start row of the next data block if
1721  // the current row is the last row of a data block and an empty
1722  // cell follows. Somewhat unexpected behaviour...
1723  // So check beforehand if there is one non-empty cell following.
1724  if (pDoc->HasData( nCol, nY + 1, nTab))
1725  {
1726  pDoc->FindAreaPos( nCol, nY, nTab, SC_MOVE_DOWN);
1727  if (nOverWriteEndRow > nY)
1728  nOverWriteEndRow = nY;
1729  }
1730  else
1731  {
1732  nOverWriteEndRow = nY;
1733  }
1734  }
1735  else
1736  {
1737  nOverWriteEndRow = 0;
1738  break; // for
1739  }
1740  }
1741 
1742  if (nOverWriteEndRow > nEndY)
1743  {
1744  FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY, nOverWriteEndRow - nEndY);
1745  return;
1746  }
1747 
1748  // Non-overwriting fill follows.
1749 
1750  const bool bDataLeft = (nStartX > 0);
1751  if (!bDataLeft && nEndX >= pDoc->MaxCol())
1752  // Absolutely no data left or right of selection.
1753  return;
1754 
1755  // Check that there is
1756  // 1) data immediately left (preferred) or right of start (row) of selection
1757  // 2) data there below
1758  // 3) no data immediately below selection
1759 
1760  SCCOL nMovX = (bDataLeft ? nStartX - 1 : nEndX + 1);
1761  SCROW nMovY = nStartY;
1762  bool bDataFound = (pDoc->HasData( nMovX, nStartY, nTab) && pDoc->HasData( nMovX, nStartY + 1, nTab));
1763  if (!bDataFound && bDataLeft && nEndX < pDoc->MaxCol())
1764  {
1765  nMovX = nEndX + 1; // check right
1766  bDataFound = (pDoc->HasData( nMovX, nStartY, nTab) && pDoc->HasData( nMovX, nStartY + 1, nTab));
1767  }
1768 
1769  if (bDataFound && pDoc->IsBlockEmpty( nTab, nStartX, nEndY + 1, nEndX, nEndY + 1, true))
1770  {
1771  // Get end of data left or right.
1772  pDoc->FindAreaPos( nMovX, nMovY, nTab, SC_MOVE_DOWN);
1773  // Find minimum end row of below empty area and data right.
1774  for (SCCOL nX = nStartX; nX <= nEndX; ++nX)
1775  {
1776  SCROW nY = nEndY + 1;
1777  // Get next row with data in this column.
1778  pDoc->FindAreaPos( nX, nY, nTab, SC_MOVE_DOWN);
1779  if (nMovY == pDoc->MaxRow() && nY == pDoc->MaxRow())
1780  {
1781  // FindAreaPos() returns MAXROW also if there is no data at all
1782  // from the start, so check if that contains data if the nearby
1783  // (left or right) data ends there and increment if no data
1784  // here, pretending the next data would be thereafter so nMovY
1785  // will not be decremented.
1786  if (!pDoc->HasData( nX, nY, nTab))
1787  ++nY;
1788  }
1789  if (nMovY > nY - 1)
1790  nMovY = nY - 1;
1791  }
1792 
1793  if (nMovY > nEndY)
1794  {
1795  FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY, nMovY - nEndY);
1796  }
1797  }
1798 }
1799 
1801 {
1802  ScRange aRange;
1803  GetViewData().GetSimpleArea(aRange);
1804  aRange.PutInOrder();
1805 
1806  ScDocShell* pDocSh = GetViewData().GetDocShell();
1807  pDocSh->GetDocFunc().ConvertFormulaToValue(aRange, true);
1808  pDocSh->PostPaint(aRange, PaintPartFlags::Grid);
1809 }
1810 
1812 {
1813  ScMarkData aFuncMark = GetViewData().GetMarkData();
1814  if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
1815  {
1816  // no selection -> use cursor position
1817 
1818  ScAddress aCursor( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() );
1819  aFuncMark.SetMarkArea( ScRange( aCursor ) );
1820  }
1821 
1822  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
1823  TransliterateText( aFuncMark, nType, false );
1824  if (bSuccess)
1825  {
1826  GetViewData().GetViewShell()->UpdateInputHandler();
1827  }
1828 }
1829 
1830 // AutoFormat
1831 
1833 {
1834  ScAutoFormatData* pData = nullptr;
1835  SCCOL nStartCol;
1836  SCROW nStartRow;
1837  SCTAB nStartTab;
1838  SCCOL nEndCol;
1839  SCROW nEndRow;
1840  SCTAB nEndTab;
1841  if (GetViewData().GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
1842  {
1843  if ( nEndCol-nStartCol >= 3 && nEndRow-nStartRow >= 3 )
1844  {
1845  ScDocument* pDoc = GetViewData().GetDocument();
1846  pData = new ScAutoFormatData;
1847  pDoc->GetAutoFormatData( nStartTab, nStartCol,nStartRow,nEndCol,nEndRow, *pData );
1848  }
1849  }
1850  return pData;
1851 }
1852 
1853 void ScViewFunc::AutoFormat( sal_uInt16 nFormatNo )
1854 {
1855  ScRange aRange;
1856  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1857  {
1858  ScDocShell* pDocSh = GetViewData().GetDocShell();
1859  ScMarkData& rMark = GetViewData().GetMarkData();
1860 
1861  bool bSuccess = pDocSh->GetDocFunc().AutoFormat( aRange, &rMark, nFormatNo, false );
1862  if (bSuccess)
1863  pDocSh->UpdateOle(&GetViewData());
1864  }
1865  else
1866  ErrorMessage(STR_NOMULTISELECT);
1867 }
1868 
1869 // Search & Replace
1870 
1872  bool bAddUndo, bool bIsApi )
1873 {
1874  SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Empty);
1875  ScDocShell* pDocSh = GetViewData().GetDocShell();
1876  ScDocument& rDoc = pDocSh->GetDocument();
1877  ScMarkData& rMark = GetViewData().GetMarkData();
1878  if (bAddUndo && !rDoc.IsUndoEnabled())
1879  bAddUndo = false;
1880 
1881  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() && (pSearchItem->HasStartPoint()) )
1882  {
1883  // No selection -> but we have a start point (top left corner of the
1884  // current view), start searching from there, not from the current
1885  // cursor position.
1886  SCCOL nPosX;
1887  SCROW nPosY;
1888 
1889  int nPixelX = pSearchItem->GetStartPointX() * GetViewData().GetPPTX();
1890  int nPixelY = pSearchItem->GetStartPointY() * GetViewData().GetPPTY();
1891 
1892  GetViewData().GetPosFromPixel(nPixelX, nPixelY, GetViewData().GetActivePart(), nPosX, nPosY);
1893 
1894  AlignToCursor( nPosX, nPosY, SC_FOLLOW_JUMP );
1895  SetCursor( nPosX, nPosY, true );
1896  }
1897 
1898  SCCOL nCol, nOldCol;
1899  SCROW nRow, nOldRow;
1900  SCTAB nTab, nOldTab;
1901  nCol = nOldCol = GetViewData().GetCurX();
1902  nRow = nOldRow = GetViewData().GetCurY();
1903  nTab = nOldTab = GetViewData().GetTabNo();
1904 
1905  SvxSearchCmd nCommand = pSearchItem->GetCommand();
1906  bool bAllTables = pSearchItem->IsAllTables();
1907  std::set<SCTAB> aOldSelectedTables;
1908  SCTAB nLastTab = rDoc.GetTableCount() - 1;
1909  SCTAB nStartTab, nEndTab;
1910  if ( bAllTables )
1911  {
1912  nStartTab = 0;
1913  nEndTab = nLastTab;
1914  std::set<SCTAB> aTmp(rMark.begin(), rMark.end());
1915  aOldSelectedTables.swap(aTmp);
1916  }
1917  else
1918  {
1919  nStartTab = rMark.GetFirstSelected();
1920  nEndTab = rMark.GetLastSelected();
1921  }
1922 
1923  if ( nCommand == SvxSearchCmd::FIND
1924  || nCommand == SvxSearchCmd::FIND_ALL)
1925  bAddUndo = false;
1926 
1928 
1929  ScDocumentUniquePtr pUndoDoc;
1930  std::unique_ptr<ScMarkData> pUndoMark;
1931  OUString aUndoStr;
1932  if (bAddUndo)
1933  {
1934  pUndoMark.reset(new ScMarkData(rMark)); // Mark is being modified
1935  if ( nCommand == SvxSearchCmd::REPLACE_ALL )
1936  {
1937  pUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
1938  pUndoDoc->InitUndo( &rDoc, nStartTab, nEndTab );
1939  }
1940  }
1941 
1942  if ( bAllTables )
1943  {
1944  for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
1945  {
1946  rMark.SelectTable( j, true );
1947  }
1948  }
1949 
1950  DoneBlockMode(true); // don't delete mark
1951  InitOwnBlockMode();
1952 
1953  // If search starts at the beginning don't ask again whether it shall start at the beginning
1954  bool bFirst = true;
1955  if ( nCol == 0 && nRow == 0 && nTab == nStartTab && !pSearchItem->GetBackward() )
1956  bFirst = false;
1957 
1958  bool bFound = false;
1959  while (true)
1960  {
1961  GetFrameWin()->EnterWait();
1962  ScRangeList aMatchedRanges;
1963  if (rDoc.SearchAndReplace(*pSearchItem, nCol, nRow, nTab, rMark, aMatchedRanges, aUndoStr, pUndoDoc.get()))
1964  {
1965  bFound = true;
1966  if (bAddUndo)
1967  {
1968  GetViewData().GetDocShell()->GetUndoManager()->AddUndoAction(
1969  std::make_unique<ScUndoReplace>( GetViewData().GetDocShell(), *pUndoMark,
1970  nCol, nRow, nTab,
1971  aUndoStr, std::move(pUndoDoc), pSearchItem ) );
1972  }
1973 
1974  if (nCommand == SvxSearchCmd::FIND_ALL || nCommand == SvxSearchCmd::REPLACE_ALL)
1975  {
1976  SfxViewFrame* pViewFrm = SfxViewFrame::Current();
1977  bool bShow = GetViewData().GetViewShell()->GetViewData().GetOptions().GetOption( VOPT_SUMMARY );
1978 
1979  if (bShow && pViewFrm && !comphelper::LibreOfficeKit::isActive())
1980  {
1981  pViewFrm->ShowChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId());
1982  SfxChildWindow* pWnd = pViewFrm->GetChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId());
1983  if (pWnd)
1984  {
1985  sc::SearchResultsDlg* pDlg = static_cast<sc::SearchResultsDlg*>(pWnd->GetController().get());
1986  if (pDlg)
1987  pDlg->FillResults(&rDoc, aMatchedRanges,
1988  pSearchItem->GetCellType() == SvxSearchCellType::NOTE);
1989  }
1990  }
1991 
1992  rMark.ResetMark();
1993  for (size_t i = 0, n = aMatchedRanges.size(); i < n; ++i)
1994  {
1995  const ScRange& r = aMatchedRanges[i];
1996  if (r.aStart.Tab() == nTab)
1997  rMark.SetMultiMarkArea(r);
1998  }
1999  }
2000 
2001  break; // break 'while (TRUE)'
2002  }
2003  else if ( bFirst && (nCommand == SvxSearchCmd::FIND ||
2004  nCommand == SvxSearchCmd::REPLACE) )
2005  {
2006  bFirst = false;
2007  GetFrameWin()->LeaveWait();
2008  if (!bIsApi)
2009  {
2010  if ( nStartTab == nEndTab )
2011  SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::EndSheet);
2012  else
2013  SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::End);
2014 
2015  rDoc.GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
2016  if (pSearchItem->GetBackward())
2017  nTab = nEndTab;
2018  else
2019  nTab = nStartTab;
2020  }
2021  else
2022  {
2023  break; // break 'while (TRUE)'
2024  }
2025  }
2026  else // nothing found
2027  {
2028  if ( nCommand == SvxSearchCmd::FIND_ALL || nCommand == SvxSearchCmd::REPLACE_ALL )
2029  {
2030  pDocSh->PostPaintGridAll(); // Mark
2031  }
2032 
2033  GetFrameWin()->LeaveWait();
2034  if (!bIsApi)
2035  {
2036  GetViewData().GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, pSearchItem->GetSearchString().toUtf8().getStr());
2037  SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NotFound);
2038  }
2039 
2040  break; // break 'while (TRUE)'
2041  }
2042  } // of while true
2043 
2044  if (!aOldSelectedTables.empty())
2045  {
2046  // restore originally selected table
2047  for (SCTAB i = 0; i <= nEndTab; ++i)
2048  rMark.SelectTable(i, false);
2049 
2050  for (const auto& rTab : aOldSelectedTables)
2051  rMark.SelectTable(rTab, true);
2052 
2053  if ( bFound )
2054  { // if a table is selected as a "match" it remains selected.
2055  rMark.SelectTable( nTab, true );
2056  // It's a swap if only one table was selected before
2058  if ( aOldSelectedTables.size() == 1 && nTab != nOldTab )
2059  rMark.SelectTable( nOldTab, false );
2060  }
2061  }
2062 
2063  // Avoid LOK selection notifications before we have all the results.
2064  GetViewData().GetViewShell()->setTiledSearching(true);
2065  MarkDataChanged();
2066  GetViewData().GetViewShell()->setTiledSearching(false);
2067 
2068  if ( bFound )
2069  {
2070  if ( nTab != GetViewData().GetTabNo() )
2071  SetTabNo( nTab );
2072 
2073  // if nothing is marked, DoneBlockMode, then marking can start
2074  // directly from this place via Shift-Cursor
2075  if (!rMark.IsMarked() && !rMark.IsMultiMarked())
2076  DoneBlockMode(true);
2077 
2078  AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
2079  SetCursor( nCol, nRow, true );
2080 
2082  {
2083  Point aCurPos = GetViewData().GetScrPos(nCol, nRow, GetViewData().GetActivePart());
2084 
2085  // just update the cell selection
2086  ScGridWindow* pGridWindow = GetViewData().GetActiveWin();
2087  // Don't move cell selection handles for find-all: selection of all but the first result would be lost.
2088  if (pGridWindow && nCommand == SvxSearchCmd::FIND)
2089  {
2090  // move the cell selection handles
2091  pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_RESET, aCurPos.X(), aCurPos.Y());
2092  pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_START, aCurPos.X(), aCurPos.Y());
2093  pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_END, aCurPos.X(), aCurPos.Y());
2094  }
2095 
2096  if (pGridWindow)
2097  {
2098  std::vector<tools::Rectangle> aLogicRects;
2099  pGridWindow->GetCellSelection(aLogicRects);
2100 
2101  boost::property_tree::ptree aTree;
2102  aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr());
2103  aTree.put("highlightAll", nCommand == SvxSearchCmd::FIND_ALL);
2104 
2105  boost::property_tree::ptree aSelections;
2106  for (const tools::Rectangle& rLogicRect : aLogicRects)
2107  {
2108  boost::property_tree::ptree aSelection;
2109  aSelection.put("part", OString::number(nTab).getStr());
2110  aSelection.put("rectangles", rLogicRect.toString().getStr());
2111  aSelections.push_back(std::make_pair("", aSelection));
2112  }
2113  aTree.add_child("searchResultSelection", aSelections);
2114 
2115  std::stringstream aStream;
2116  boost::property_tree::write_json(aStream, aTree);
2117  OString aPayload = aStream.str().c_str();
2118  SfxViewShell* pViewShell = GetViewData().GetViewShell();
2119  pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
2120 
2121  // Trigger LOK_CALLBACK_TEXT_SELECTION now.
2122  MarkDataChanged();
2123  }
2124  }
2125 
2126  if ( nCommand == SvxSearchCmd::REPLACE
2127  || nCommand == SvxSearchCmd::REPLACE_ALL )
2128  {
2129  if ( nCommand == SvxSearchCmd::REPLACE )
2130  {
2131  pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PaintPartFlags::Grid );
2132 
2133  // jump to next cell if we replaced everything in the cell
2134  // where the cursor was positioned (but avoid switching tabs)
2135  if ( nCol == nOldCol && nRow == nOldRow && nTab == nOldTab )
2136  {
2137  SvxSearchItem aSearchItem = ScGlobal::GetSearchItem();
2138  aSearchItem.SetCommand(SvxSearchCmd::FIND);
2139  aSearchItem.SetWhich(SID_SEARCH_ITEM);
2140 
2141  ScRangeList aMatchedRanges;
2142  ScTable::UpdateSearchItemAddressForReplace( aSearchItem, nCol, nRow );
2143  if ( rDoc.SearchAndReplace( aSearchItem, nCol, nRow, nTab, rMark, aMatchedRanges, aUndoStr ) &&
2144  ( nTab == nOldTab ) &&
2145  ( nCol != nOldCol || nRow != nOldRow ) )
2146  {
2147  AlignToCursor(nCol, nRow, SC_FOLLOW_JUMP);
2148  SetCursor( nCol, nRow, true );
2149  }
2150  }
2151  }
2152  else
2153  pDocSh->PostPaintGridAll();
2154  pDocSh->SetDocumentModified();
2155  }
2156  else if ( nCommand == SvxSearchCmd::FIND_ALL )
2157  pDocSh->PostPaintGridAll(); // mark
2158  GetFrameWin()->LeaveWait();
2159  }
2160  return bFound;
2161 }
2162 
2163 // Goal Seek
2164 
2165 void ScViewFunc::Solve( const ScSolveParam& rParam )
2166 {
2167  ScDocument* pDoc = GetViewData().GetDocument();
2168 
2169  if ( pDoc )
2170  {
2171  SCCOL nDestCol = rParam.aRefVariableCell.Col();
2172  SCROW nDestRow = rParam.aRefVariableCell.Row();
2173  SCTAB nDestTab = rParam.aRefVariableCell.Tab();
2174 
2175  ScEditableTester aTester( pDoc, nDestTab, nDestCol,nDestRow, nDestCol,nDestRow );
2176  if (!aTester.IsEditable())
2177  {
2178  ErrorMessage(aTester.GetMessageId());
2179  return;
2180  }
2181 
2182  OUString aTargetValStr;
2183  if ( rParam.pStrTargetVal )
2184  aTargetValStr = *rParam.pStrTargetVal;
2185 
2186  OUString aMsgStr;
2187  OUString aResStr;
2188  double nSolveResult;
2189 
2190  GetFrameWin()->EnterWait();
2191 
2192  bool bExact =
2193  pDoc->Solver(
2194  rParam.aRefFormulaCell.Col(),
2195  rParam.aRefFormulaCell.Row(),
2196  rParam.aRefFormulaCell.Tab(),
2197  nDestCol, nDestRow, nDestTab,
2198  aTargetValStr,
2199  nSolveResult );
2200 
2201  GetFrameWin()->LeaveWait();
2202 
2203  SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2204  sal_uLong nFormat = 0;
2205  const ScPatternAttr* pPattern = pDoc->GetPattern( nDestCol, nDestRow, nDestTab );
2206  if ( pPattern )
2207  nFormat = pPattern->GetNumberFormat( pFormatter );
2208  Color* p;
2209  pFormatter->GetOutputString( nSolveResult, nFormat, aResStr, &p );
2210 
2211  if ( bExact )
2212  {
2213  aMsgStr += ScResId( STR_MSSG_SOLVE_0 ) +
2214  aResStr +
2215  ScResId( STR_MSSG_SOLVE_1 );
2216  }
2217  else
2218  {
2219  aMsgStr = ScResId( STR_MSSG_SOLVE_2 ) +
2220  ScResId( STR_MSSG_SOLVE_3 ) +
2221  aResStr +
2222  ScResId( STR_MSSG_SOLVE_4 );
2223  }
2224 
2225  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetViewData().GetDialogParent(),
2226  VclMessageType::Question, VclButtonsType::YesNo, aMsgStr));
2227  xBox->set_title(ScResId(STR_MSSG_DOSUBTOTALS_0));
2228  xBox->set_default_response(RET_NO);
2229  if (xBox->run() == RET_YES)
2230  EnterValue( nDestCol, nDestRow, nDestTab, nSolveResult );
2231 
2232  GetViewData().GetViewShell()->UpdateInputHandler( true );
2233  }
2234 }
2235 
2236 // multi operation
2237 
2238 void ScViewFunc::TabOp( const ScTabOpParam& rParam, bool bRecord )
2239 {
2240  ScRange aRange;
2241  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
2242  {
2243  ScDocShell* pDocSh = GetViewData().GetDocShell();
2244  ScMarkData& rMark = GetViewData().GetMarkData();
2245  pDocSh->GetDocFunc().TabOp( aRange, &rMark, rParam, bRecord, false );
2246  }
2247  else
2248  ErrorMessage(STR_NOMULTISELECT);
2249 }
2250 
2251 void ScViewFunc::MakeScenario( const OUString& rName, const OUString& rComment,
2252  const Color& rColor, ScScenarioFlags nFlags )
2253 {
2254  ScDocShell* pDocSh = GetViewData().GetDocShell();
2255  ScMarkData& rMark = GetViewData().GetMarkData();
2256  SCTAB nTab = GetViewData().GetTabNo();
2257 
2258  SCTAB nNewTab = pDocSh->MakeScenario( nTab, rName, rComment, rColor, nFlags, rMark );
2259  if (nFlags & ScScenarioFlags::CopyAll)
2260  SetTabNo( nNewTab, true ); // ScScenarioFlags::CopyAll -> visible
2261  else
2262  {
2263  SfxBindings& rBindings = GetViewData().GetBindings();
2264  rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar
2265  rBindings.Invalidate( SID_ROWCOL_SELCOUNT ); // Statusbar
2266  rBindings.Invalidate( SID_TABLES_COUNT );
2267  rBindings.Invalidate( SID_SELECT_SCENARIO );
2268  rBindings.Invalidate( FID_TABLE_SHOW );
2269  }
2270 }
2271 
2273 {
2274  ScEditableTester aTester( this );
2275  if (!aTester.IsEditable())
2276  {
2277  ErrorMessage(aTester.GetMessageId());
2278  return;
2279  }
2280 
2281  // Undo: apply attributes
2282 
2283  ScDocument* pDoc = GetViewData().GetDocument();
2284  ScPatternAttr aPattern( pDoc->GetPool() );
2285  aPattern.GetItemSet().Put( ScMergeFlagAttr( ScMF::Scenario ) );
2286  aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
2287  ApplySelectionPattern(aPattern);
2288 }
2289 
2290 void ScViewFunc::UseScenario( const OUString& rName )
2291 {
2292  ScDocShell* pDocSh = GetViewData().GetDocShell();
2293  SCTAB nTab = GetViewData().GetTabNo();
2294 
2295  DoneBlockMode();
2296  InitOwnBlockMode();
2297  pDocSh->UseScenario( nTab, rName );
2298 }
2299 
2300 // Insert table
2301 
2302 bool ScViewFunc::InsertTable( const OUString& rName, SCTAB nTab, bool bRecord )
2303 {
2304  // Order Table/Name is inverted for DocFunc
2305  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
2306  InsertTable( nTab, rName, bRecord, false );
2307  if (bSuccess)
2308  SetTabNo( nTab, true );
2309 
2310  return bSuccess;
2311 }
2312 
2313 // Insert tables
2314 
2315 void ScViewFunc::InsertTables(std::vector<OUString>& aNames, SCTAB nTab,
2316  SCTAB nCount, bool bRecord )
2317 {
2318  ScDocShell* pDocSh = GetViewData().GetDocShell();
2319  ScDocument& rDoc = pDocSh->GetDocument();
2320  if (bRecord && !rDoc.IsUndoEnabled())
2321  bRecord = false;
2322 
2323  WaitObject aWait( GetFrameWin() );
2324 
2325  if (bRecord)
2326  {
2327  rDoc.BeginDrawUndo(); // InsertTab creates a SdrUndoNewPage
2328  }
2329 
2330  bool bFlag=false;
2331 
2332  if(aNames.empty())
2333  {
2334  rDoc.CreateValidTabNames(aNames, nCount);
2335  }
2336  if (rDoc.InsertTabs(nTab, aNames))
2337  {
2338  pDocSh->Broadcast( ScTablesHint( SC_TABS_INSERTED, nTab, nCount ) );
2339  bFlag = true;
2340  }
2341 
2342  if (bFlag)
2343  {
2344  if (bRecord)
2345  pDocSh->GetUndoManager()->AddUndoAction(
2346  std::make_unique<ScUndoInsertTables>( pDocSh, nTab, aNames));
2347 
2348  // Update views
2349 
2350  SetTabNo( nTab, true );
2351  pDocSh->PostPaintExtras();
2352  pDocSh->SetDocumentModified();
2353  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2354  }
2355 }
2356 
2357 bool ScViewFunc::AppendTable( const OUString& rName, bool bRecord )
2358 {
2359  ScDocShell* pDocSh = GetViewData().GetDocShell();
2360  ScDocument& rDoc = pDocSh->GetDocument();
2361  if (bRecord && !rDoc.IsUndoEnabled())
2362  bRecord = false;
2363 
2364  WaitObject aWait( GetFrameWin() );
2365 
2366  if (bRecord)
2367  rDoc.BeginDrawUndo(); // InsertTab creates a SdrUndoNewPage
2368 
2369  if (rDoc.InsertTab( SC_TAB_APPEND, rName ))
2370  {
2371  SCTAB nTab = rDoc.GetTableCount()-1;
2372  if (bRecord)
2373  pDocSh->GetUndoManager()->AddUndoAction(
2374  std::make_unique<ScUndoInsertTab>( pDocSh, nTab, true, rName));
2375  GetViewData().InsertTab( nTab );
2376  SetTabNo( nTab, true );
2377  pDocSh->PostPaintExtras();
2378  pDocSh->SetDocumentModified();
2379  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2380  return true;
2381  }
2382  else
2383  {
2384  return false;
2385  }
2386 }
2387 
2388 void ScViewFunc::DeleteTable( SCTAB nTab, bool bRecord )
2389 {
2390  ScDocShell* pDocSh = GetViewData().GetDocShell();
2391  ScDocument& rDoc = pDocSh->GetDocument();
2392 
2393  bool bSuccess = pDocSh->GetDocFunc().DeleteTable( nTab, bRecord );
2394  if (bSuccess)
2395  {
2396  SCTAB nNewTab = nTab;
2397  if ( nNewTab >= rDoc.GetTableCount() )
2398  --nNewTab;
2399  SetTabNo( nNewTab, true );
2400  }
2401 }
2402 
2403 //only use this method for undo for now, all sheets must be connected
2404 //this method doesn't support undo for now, merge it when it with the other method later
2405 void ScViewFunc::DeleteTables( const SCTAB nTab, SCTAB nSheets )
2406 {
2407  ScDocShell* pDocSh = GetViewData().GetDocShell();
2408  ScDocument& rDoc = pDocSh->GetDocument();
2409  bool bVbaEnabled = rDoc.IsInVBAMode();
2410  SCTAB nNewTab = nTab;
2411  WaitObject aWait( GetFrameWin() );
2412 
2413  while ( nNewTab > 0 && !rDoc.IsVisible( nNewTab ) )
2414  --nNewTab;
2415 
2416  if (rDoc.DeleteTabs(nTab, nSheets))
2417  {
2418  if( bVbaEnabled )
2419  {
2420  for (SCTAB aTab = 0; aTab < nSheets; ++aTab)
2421  {
2422  OUString sCodeName;
2423  bool bHasCodeName = rDoc.GetCodeName( nTab + aTab, sCodeName );
2424  if ( bHasCodeName )
2425  VBA_DeleteModule( *pDocSh, sCodeName );
2426  }
2427  }
2428 
2429  pDocSh->Broadcast( ScTablesHint( SC_TABS_DELETED, nTab, nSheets ) );
2430  if ( nNewTab >= rDoc.GetTableCount() )
2431  nNewTab = rDoc.GetTableCount() - 1;
2432  SetTabNo( nNewTab, true );
2433 
2434  pDocSh->PostPaintExtras();
2435  pDocSh->SetDocumentModified();
2436 
2437  SfxApplication* pSfxApp = SfxGetpApp(); // Navigator
2438  pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2439  pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
2440  pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
2441  }
2442 }
2443 
2444 bool ScViewFunc::DeleteTables(const vector<SCTAB> &TheTabs, bool bRecord )
2445 {
2446  ScDocShell* pDocSh = GetViewData().GetDocShell();
2447  ScDocument& rDoc = pDocSh->GetDocument();
2448  bool bVbaEnabled = rDoc.IsInVBAMode();
2449  SCTAB nNewTab = TheTabs.front();
2450  WaitObject aWait( GetFrameWin() );
2451  if (bRecord && !rDoc.IsUndoEnabled())
2452  bRecord = false;
2453  if ( bVbaEnabled )
2454  bRecord = false;
2455 
2456  while ( nNewTab > 0 && !rDoc.IsVisible( nNewTab ) )
2457  --nNewTab;
2458 
2459  bool bWasLinked = false;
2460  ScDocumentUniquePtr pUndoDoc;
2461  std::unique_ptr<ScRefUndoData> pUndoData;
2462  if (bRecord)
2463  {
2464  pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
2465  SCTAB nCount = rDoc.GetTableCount();
2466 
2467  OUString aOldName;
2468  for(size_t i=0; i<TheTabs.size(); ++i)
2469  {
2470  SCTAB nTab = TheTabs[i];
2471  if (i==0)
2472  pUndoDoc->InitUndo( &rDoc, nTab,nTab, true,true ); // incl. column/fow flags
2473  else
2474  pUndoDoc->AddUndoTab( nTab,nTab, true,true ); // incl. column/fow flags
2475 
2476  rDoc.CopyToDocument(0,0,nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab, InsertDeleteFlags::ALL,false, *pUndoDoc );
2477  rDoc.GetName( nTab, aOldName );
2478  pUndoDoc->RenameTab( nTab, aOldName );
2479  if (rDoc.IsLinked(nTab))
2480  {
2481  bWasLinked = true;
2482  pUndoDoc->SetLink( nTab, rDoc.GetLinkMode(nTab), rDoc.GetLinkDoc(nTab),
2483  rDoc.GetLinkFlt(nTab), rDoc.GetLinkOpt(nTab),
2484  rDoc.GetLinkTab(nTab),
2485  rDoc.GetLinkRefreshDelay(nTab) );
2486  }
2487  if ( rDoc.IsScenario(nTab) )
2488  {
2489  pUndoDoc->SetScenario( nTab, true );
2490  OUString aComment;
2491  Color aColor;
2492  ScScenarioFlags nScenFlags;
2493  rDoc.GetScenarioData( nTab, aComment, aColor, nScenFlags );
2494  pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
2495  bool bActive = rDoc.IsActiveScenario( nTab );
2496  pUndoDoc->SetActiveScenario( nTab, bActive );
2497  }
2498  pUndoDoc->SetVisible( nTab, rDoc.IsVisible( nTab ) );
2499  pUndoDoc->SetTabBgColor( nTab, rDoc.GetTabBgColor(nTab) );
2500  auto pSheetEvents = rDoc.GetSheetEvents( nTab );
2501  pUndoDoc->SetSheetEvents( nTab, std::unique_ptr<ScSheetEvents>(pSheetEvents ? new ScSheetEvents(*pSheetEvents) : nullptr) );
2502  pUndoDoc->SetLayoutRTL( nTab, rDoc.IsLayoutRTL( nTab ) );
2503 
2504  if ( rDoc.IsTabProtected( nTab ) )
2505  pUndoDoc->SetTabProtection(nTab, rDoc.GetTabProtection(nTab));
2506 
2507  // Drawing-Layer is responsible for its Undo !!!
2508  // pUndoDoc->TransferDrawPage(pDoc, nTab,nTab);
2509  }
2510 
2511  pUndoDoc->AddUndoTab( 0, nCount-1 ); // all Tabs for references
2512 
2513  rDoc.BeginDrawUndo(); // DeleteTab creates a SdrUndoDelPage
2514 
2515  pUndoData.reset(new ScRefUndoData( &rDoc ));
2516  }
2517 
2518  bool bDelDone = false;
2519 
2520  for(int i=TheTabs.size()-1; i>=0; --i)
2521  {
2522  OUString sCodeName;
2523  bool bHasCodeName = rDoc.GetCodeName( TheTabs[i], sCodeName );
2524  if (rDoc.DeleteTab(TheTabs[i]))
2525  {
2526  bDelDone = true;
2527  if( bVbaEnabled && bHasCodeName )
2528  {
2529  VBA_DeleteModule( *pDocSh, sCodeName );
2530  }
2531  pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[i] ) );
2532  }
2533  }
2534  if (bRecord)
2535  {
2536  pDocSh->GetUndoManager()->AddUndoAction(
2537  std::make_unique<ScUndoDeleteTab>( GetViewData().GetDocShell(), TheTabs,
2538  std::move(pUndoDoc), std::move(pUndoData) ));
2539  }
2540 
2541  if (bDelDone)
2542  {
2543  if ( nNewTab >= rDoc.GetTableCount() )
2544  nNewTab = rDoc.GetTableCount() - 1;
2545 
2546  SetTabNo( nNewTab, true );
2547 
2548  if (bWasLinked)
2549  {
2550  pDocSh->UpdateLinks(); // update Link-Manager
2551  GetViewData().GetBindings().Invalidate(SID_LINKS);
2552  }
2553 
2554  pDocSh->PostPaintExtras();
2555  pDocSh->SetDocumentModified();
2556 
2557  SfxApplication* pSfxApp = SfxGetpApp(); // Navigator
2558  pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2559  pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
2560  pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
2561  }
2562  return bDelDone;
2563 }
2564 
2565 bool ScViewFunc::RenameTable( const OUString& rName, SCTAB nTab )
2566 {
2567  // order Table/Name is inverted for DocFunc
2568  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().
2569  RenameTable( nTab, rName, true, false );
2570  if (bSuccess)
2571  {
2572  // the table name might be part of a formula
2573  GetViewData().GetViewShell()->UpdateInputHandler();
2574  }
2575  return bSuccess;
2576 }
2577 
2578 bool ScViewFunc::SetTabBgColor( const Color& rColor, SCTAB nTab )
2579 {
2580  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().SetTabBgColor( nTab, rColor, true, false );
2581  if (bSuccess)
2582  {
2583  GetViewData().GetViewShell()->UpdateInputHandler();
2584  }
2585  return bSuccess;
2586 }
2587 
2588 bool ScViewFunc::SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList )
2589 {
2590  bool bSuccess = GetViewData().GetDocShell()->GetDocFunc().SetTabBgColor( rUndoSetTabBgColorInfoList, false );
2591  if (bSuccess)
2592  {
2593  GetViewData().GetViewShell()->UpdateInputHandler();
2594  }
2595  return bSuccess;
2596 }
2597 
2598 void ScViewFunc::InsertAreaLink( const OUString& rFile,
2599  const OUString& rFilter, const OUString& rOptions,
2600  const OUString& rSource )
2601 {
2602  ScDocShell* pDocSh = GetViewData().GetDocShell();
2603  SCCOL nPosX = GetViewData().GetCurX();
2604  SCROW nPosY = GetViewData().GetCurY();
2605  SCTAB nTab = GetViewData().GetTabNo();
2606  ScAddress aPos( nPosX, nPosY, nTab );
2607 
2608  pDocSh->GetDocFunc().InsertAreaLink( rFile, rFilter, rOptions, rSource, aPos, 0/*nRefresh*/, false, false );
2609 }
2610 
2611 void ScViewFunc::InsertTableLink( const OUString& rFile,
2612  const OUString& rFilter, const OUString& rOptions,
2613  const OUString& rTabName )
2614 {
2615  OUString aFilterName = rFilter;
2616  OUString aOpt = rOptions;
2617  ScDocumentLoader aLoader( rFile, aFilterName, aOpt );
2618  if (!aLoader.IsError())
2619  {
2620  ScDocShell* pSrcSh = aLoader.GetDocShell();
2621  ScDocument& rSrcDoc = pSrcSh->GetDocument();
2622  SCTAB nTab = MAXTAB+1;
2623  if (rTabName.isEmpty()) // no name given -> first table
2624  nTab = 0;
2625  else
2626  {
2627  OUString aTemp;
2628  SCTAB nCount = rSrcDoc.GetTableCount();
2629  for (SCTAB i=0; i<nCount; i++)
2630  {
2631  rSrcDoc.GetName( i, aTemp );
2632  if ( aTemp == rTabName )
2633  nTab = i;
2634  }
2635  }
2636 
2637  if ( nTab <= MAXTAB )
2638  ImportTables( pSrcSh, 1, &nTab, true,
2639  GetViewData().GetTabNo() );
2640  }
2641 }
2642 
2643 // Copy/link tables from another document
2644 
2646  SCTAB nCount, const SCTAB* pSrcTabs, bool bLink,SCTAB nTab )
2647 {
2648  ScDocument& rSrcDoc = pSrcShell->GetDocument();
2649 
2650  ScDocShell* pDocSh = GetViewData().GetDocShell();
2651  ScDocument& rDoc = pDocSh->GetDocument();
2652  bool bUndo(rDoc.IsUndoEnabled());
2653 
2654  bool bError = false;
2655  bool bRefs = false;
2656  bool bName = false;
2657 
2658  if (rSrcDoc.GetDrawLayer())
2659  pDocSh->MakeDrawLayer();
2660 
2661  if (bUndo)
2662  rDoc.BeginDrawUndo(); // drawing layer must do its own undo actions
2663 
2664  SCTAB nInsCount = 0;
2665  SCTAB i;
2666  for( i=0; i<nCount; i++ )
2667  { // insert sheets first and update all references
2668  OUString aName;
2669  rSrcDoc.GetName( pSrcTabs[i], aName );
2670  rDoc.CreateValidTabName( aName );
2671  if ( !rDoc.InsertTab( nTab+i, aName ) )
2672  {
2673  bError = true; // total error
2674  break; // for
2675  }
2676  ++nInsCount;
2677  }
2678  for (i=0; i<nCount && !bError; i++)
2679  {
2680  SCTAB nSrcTab = pSrcTabs[i];
2681  SCTAB nDestTab1=nTab+i;
2682  sal_uLong nErrVal = pDocSh->TransferTab( *pSrcShell, nSrcTab, nDestTab1,
2683  false, false ); // no insert
2684 
2685  switch (nErrVal)
2686  {
2687  case 0: // internal error or full of errors
2688  bError = true;
2689  break;
2690  case 2:
2691  bRefs = true;
2692  break;
2693  case 3:
2694  bName = true;
2695  break;
2696  case 4:
2697  bRefs = bName = true;
2698  break;
2699  }
2700 
2701  }
2702 
2703  if (bLink)
2704  {
2705  sfx2::LinkManager* pLinkManager = rDoc.GetLinkManager();
2706 
2707  SfxMedium* pMed = pSrcShell->GetMedium();
2708  OUString aFileName = pMed->GetName();
2709  OUString aFilterName;
2710  if (pMed->GetFilter())
2711  aFilterName = pMed->GetFilter()->GetFilterName();
2712  OUString aOptions = ScDocumentLoader::GetOptions(*pMed);
2713 
2714  bool bWasThere = rDoc.HasLink( aFileName, aFilterName, aOptions );
2715 
2716  sal_uLong nRefresh = 0;
2717  OUString aTabStr;
2718  for (i=0; i<nInsCount; i++)
2719  {
2720  rSrcDoc.GetName( pSrcTabs[i], aTabStr );
2721  rDoc.SetLink( nTab+i, ScLinkMode::NORMAL,
2722  aFileName, aFilterName, aOptions, aTabStr, nRefresh );
2723  }
2724 
2725  if (!bWasThere) // Insert link only once per source document
2726  {
2727  ScTableLink* pLink = new ScTableLink( pDocSh, aFileName, aFilterName, aOptions, nRefresh );
2728  pLink->SetInCreate( true );
2729  pLinkManager->InsertFileLink( *pLink, sfx2::SvBaseLinkObjectType::ClientFile, aFileName, &aFilterName );
2730  pLink->Update();
2731  pLink->SetInCreate( false );
2732 
2733  SfxBindings& rBindings = GetViewData().GetBindings();
2734  rBindings.Invalidate( SID_LINKS );
2735  }
2736  }
2737 
2738  if (bUndo)
2739  {
2740  pDocSh->GetUndoManager()->AddUndoAction(
2741  std::make_unique<ScUndoImportTab>( pDocSh, nTab, nCount ) );
2742  }
2743 
2744  for (i=0; i<nInsCount; i++)
2745  GetViewData().InsertTab(nTab);
2746  SetTabNo(nTab,true);
2747  pDocSh->PostPaint( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB,
2749 
2750  SfxApplication* pSfxApp = SfxGetpApp();
2751  pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2752  pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
2753 
2754  pDocSh->PostPaintExtras();
2755  pDocSh->PostPaintGridAll();
2756  pDocSh->SetDocumentModified();
2757 
2758  if (bRefs)
2759  ErrorMessage(STR_ABSREFLOST);
2760  if (bName)
2761  ErrorMessage(STR_NAMECONFLICT);
2762 }
2763 
2764 // Move/Copy table to another document
2765 
2767  sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy, const OUString* pNewTabName )
2768 {
2769  ScDocument* pDoc = GetViewData().GetDocument();
2770  ScDocShell* pDocShell = GetViewData().GetDocShell();
2771  ScDocument* pDestDoc = nullptr;
2772  ScDocShell* pDestShell = nullptr;
2773  ScTabViewShell* pDestViewSh = nullptr;
2774  bool bUndo (pDoc->IsUndoEnabled());
2775  bool bRename = pNewTabName && !pNewTabName->isEmpty();
2776 
2777  bool bNewDoc = (nDestDocNo == SC_DOC_NEW);
2778  if ( bNewDoc )
2779  {
2780  nDestTab = 0; // firstly insert
2781 
2782  // execute without SfxCallMode::RECORD, because already contained in move command
2783 
2784  SfxStringItem aItem( SID_FILE_NAME, "private:factory/" STRING_SCAPP );
2785  SfxStringItem aTarget( SID_TARGETNAME, "_blank" );
2786 
2787  const SfxPoolItem* pRetItem = GetViewData().GetDispatcher().ExecuteList(
2788  SID_OPENDOC, SfxCallMode::API|SfxCallMode::SYNCHRON,
2789  { &aItem, &aTarget });
2790  if ( pRetItem )
2791  {
2792  if ( auto pObjectItem = dynamic_cast<const SfxObjectItem*>(pRetItem) )
2793  pDestShell = dynamic_cast<ScDocShell*>( pObjectItem->GetShell() );
2794  else if ( auto pViewFrameItem = dynamic_cast<const SfxViewFrameItem*>( pRetItem) )
2795  {
2796  SfxViewFrame* pFrm = pViewFrameItem->GetFrame();
2797  if (pFrm)
2798  pDestShell = dynamic_cast<ScDocShell*>( pFrm->GetObjectShell() );
2799  }
2800  if (pDestShell)
2801  pDestViewSh = pDestShell->GetBestViewShell();
2802  }
2803  }
2804  else
2805  pDestShell = ScDocShell::GetShellByNum( nDestDocNo );
2806 
2807  if (!pDestShell)
2808  {
2809  OSL_FAIL("Destination document not found !!!");
2810  return;
2811  }
2812 
2813  ScMarkData& rMark = GetViewData().GetMarkData();
2814  if (bRename && rMark.GetSelectCount() != 1)
2815  {
2816  // Custom sheet name is provided, but more than one sheet is selected.
2817  // We don't support this scenario at the moment.
2818  return;
2819  }
2820 
2821  pDestDoc = &pDestShell->GetDocument();
2822 
2823  if (pDestDoc != pDoc)
2824  {
2825  if (bNewDoc)
2826  {
2827  while (pDestDoc->GetTableCount() > 1)
2828  pDestDoc->DeleteTab(0);
2829  pDestDoc->RenameTab( 0, "______42_____" );
2830  }
2831 
2832  SCTAB nTabCount = pDoc->GetTableCount();
2833  SCTAB nTabSelCount = rMark.GetSelectCount();
2834 
2835  vector<SCTAB> TheTabs;
2836 
2837  for(SCTAB i=0; i<nTabCount; ++i)
2838  {
2839  if(rMark.GetTableSelect(i))
2840  {
2841  OUString aTabName;
2842  pDoc->GetName( i, aTabName);
2843  TheTabs.push_back(i);
2844  for(SCTAB j=i+1;j<nTabCount;j++)
2845  {
2846  if((!pDoc->IsVisible(j)) && pDoc->IsScenario(j))
2847  {
2848  pDoc->GetName( j, aTabName);
2849  TheTabs.push_back(j);
2850  i=j;
2851  }
2852  else break;
2853  }
2854  }
2855  }
2856 
2857  GetFrameWin()->EnterWait();
2858 
2859  if (pDoc->GetDrawLayer())
2860  pDestShell->MakeDrawLayer();
2861 
2862  if (!bNewDoc && bUndo)
2863  pDestDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
2864 
2865  sal_uLong nErrVal =1;
2866  if(nDestTab==SC_TAB_APPEND)
2867  nDestTab=pDestDoc->GetTableCount();
2868  SCTAB nDestTab1=nDestTab;
2869  ScClipParam aParam;
2870  for( size_t j=0; j<TheTabs.size(); ++j, ++nDestTab1 )
2871  { // insert sheets first and update all references
2872  OUString aName;
2873  if (bRename)
2874  aName = *pNewTabName;
2875  else
2876  pDoc->GetName( TheTabs[j], aName );
2877 
2878  pDestDoc->CreateValidTabName( aName );
2879  if ( !pDestDoc->InsertTab( nDestTab1, aName ) )
2880  {
2881  nErrVal = 0; // total error
2882  break; // for
2883  }
2884  ScRange aRange( 0, 0, TheTabs[j], pDoc->MaxCol(), pDoc->MaxRow(), TheTabs[j] );
2885  aParam.maRanges.push_back(aRange);
2886  }
2887  pDoc->SetClipParam(aParam);
2888  if ( nErrVal > 0 )
2889  {
2890  nDestTab1 = nDestTab;
2891  for(SCTAB nTab : TheTabs)
2892  {
2893  nErrVal = pDestShell->TransferTab( *pDocShell, nTab, nDestTab1, false, false );
2894  nDestTab1++;
2895  }
2896  }
2897  OUString sName;
2898  if (!bNewDoc && bUndo)
2899  {
2900  pDestDoc->GetName(nDestTab, sName);
2901  pDestShell->GetUndoManager()->AddUndoAction(
2902  std::make_unique<ScUndoImportTab>( pDestShell, nDestTab,
2903  static_cast<SCTAB>(TheTabs.size())));
2904 
2905  }
2906  else
2907  {
2908  pDestShell->GetUndoManager()->Clear();
2909  }
2910 
2911  GetFrameWin()->LeaveWait();
2912  switch (nErrVal)
2913  {
2914  case 0: // internal error or full of errors
2915  {
2916  ErrorMessage(STR_TABINSERT_ERROR);
2917  return;
2918  }
2919  case 2:
2920  ErrorMessage(STR_ABSREFLOST);
2921  break;
2922  case 3:
2923  ErrorMessage(STR_NAMECONFLICT);
2924  break;
2925  case 4:
2926  {
2927  ErrorMessage(STR_ABSREFLOST);
2928  ErrorMessage(STR_NAMECONFLICT);
2929  }
2930  break;
2931  default:
2932  break;
2933  }
2934 
2935  if (!bCopy)
2936  {
2937  if(nTabCount!=nTabSelCount)
2938  DeleteTables(TheTabs); // incl. Paint & Undo
2939  else
2940  ErrorMessage(STR_TABREMOVE_ERROR);
2941  }
2942 
2943  if (bNewDoc)
2944  {
2945  // ChartListenerCollection must be updated before DeleteTab
2946  if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() )
2947  pDestDoc->UpdateChartListenerCollection();
2948 
2949  SCTAB nNumTabsInserted = static_cast<SCTAB>(TheTabs.size());
2950  pDestShell->Broadcast( ScTablesHint( SC_TABS_INSERTED, 0, nNumTabsInserted ) );
2951 
2952  pDestDoc->DeleteTab( nNumTabsInserted ); // old first table
2953  pDestShell->Broadcast( ScTablesHint( SC_TAB_DELETED, nNumTabsInserted ) );
2954 
2955  if (pDestViewSh)
2956  {
2957  // Make sure to clear the cached page view after sheet
2958  // deletion, which still points to the sdr page belonging to
2959  // the deleted sheet.
2960  SdrView* pSdrView = pDestViewSh->GetScDrawView();
2961  if (pSdrView)
2962  pSdrView->ClearPageView();
2963 
2964  pDestViewSh->TabChanged(); // pages on the drawing layer
2965  }
2966  pDestShell->PostPaint( 0,0,0, pDoc->MaxCol(), pDoc->MaxRow(), MAXTAB,
2969  // PaintPartFlags::Size for outline
2970  }
2971  else
2972  {
2973  pDestShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestTab ) );
2974  pDestShell->PostPaintExtras();
2975  pDestShell->PostPaintGridAll();
2976  }
2977 
2978  TheTabs.clear();
2979 
2980  pDestShell->SetDocumentModified();
2981  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
2982  }
2983  else
2984  {
2985  // Move or copy within the same document.
2986  SCTAB nTabCount = pDoc->GetTableCount();
2987 
2988  unique_ptr< vector<SCTAB> > pSrcTabs(new vector<SCTAB>);
2989  unique_ptr< vector<SCTAB> > pDestTabs(new vector<SCTAB>);
2990  unique_ptr< vector<OUString> > pTabNames(new vector<OUString>);
2991  unique_ptr< vector<OUString> > pDestNames;
2992  pSrcTabs->reserve(nTabCount);
2993  pDestTabs->reserve(nTabCount);
2994  pTabNames->reserve(nTabCount);
2995  OUString aDestName;
2996 
2997  for(SCTAB i=0;i<nTabCount;i++)
2998  {
2999  if(rMark.GetTableSelect(i))
3000  {
3001  OUString aTabName;
3002  pDoc->GetName( i, aTabName);
3003  pTabNames->push_back(aTabName);
3004 
3005  for(SCTAB j=i+1;j<nTabCount;j++)
3006  {
3007  if((!pDoc->IsVisible(j)) && pDoc->IsScenario(j))
3008  {
3009  pDoc->GetName( j, aTabName);
3010  pTabNames->push_back(aTabName);
3011  i=j;
3012  }
3013  else break;
3014  }
3015  }
3016  }
3017 
3018  if (bCopy && bUndo)
3019  pDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
3020 
3021  pDoc->GetName( nDestTab, aDestName);
3022  SCTAB nDestTab1=nDestTab;
3023  SCTAB nMovTab=0;
3024  for (size_t j = 0, n = pTabNames->size(); j < n; ++j)
3025  {
3026  nTabCount = pDoc->GetTableCount();
3027  const OUString& rStr = (*pTabNames)[j];
3028  if(!pDoc->GetTable(rStr,nMovTab))
3029  {
3030  nMovTab=nTabCount;
3031  }
3032  if(!pDoc->GetTable(aDestName,nDestTab1))
3033  {
3034  nDestTab1=nTabCount;
3035  }
3036  pDocShell->MoveTable( nMovTab, nDestTab1, bCopy, false ); // Undo is here
3037 
3038  if(bCopy && pDoc->IsScenario(nMovTab))
3039  {
3040  OUString aComment;
3041  Color aColor;
3042  ScScenarioFlags nFlags;
3043 
3044  pDoc->GetScenarioData(nMovTab, aComment,aColor, nFlags);
3045  pDoc->SetScenario(nDestTab1,true);
3046  pDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags);
3047  bool bActive = pDoc->IsActiveScenario(nMovTab );
3048  pDoc->SetActiveScenario( nDestTab1, bActive );
3049  bool bVisible=pDoc->IsVisible(nMovTab);
3050  pDoc->SetVisible(nDestTab1,bVisible );
3051  }
3052 
3053  pSrcTabs->push_back(nMovTab);
3054 
3055  if(!bCopy)
3056  {
3057  if(!pDoc->GetTable(rStr,nDestTab1))
3058  {
3059  nDestTab1=nTabCount;
3060  }
3061  }
3062 
3063  pDestTabs->push_back(nDestTab1);
3064  }
3065 
3066  // Rename must be done after all sheets have been moved.
3067  if (bRename)
3068  {
3069  pDestNames.reset(new vector<OUString>);
3070  size_t n = pDestTabs->size();
3071  pDestNames->reserve(n);
3072  for (size_t j = 0; j < n; ++j)
3073  {
3074  SCTAB nRenameTab = (*pDestTabs)[j];
3075  OUString aTabName = *pNewTabName;
3076  pDoc->CreateValidTabName( aTabName );
3077  pDestNames->push_back(aTabName);
3078  pDoc->RenameTab(nRenameTab, aTabName);
3079  }
3080  }
3081  else
3082  // No need to keep this around when we are not renaming.
3083  pTabNames.reset();
3084 
3085  SCTAB nTab = GetViewData().GetTabNo();
3086 
3087  if (bUndo)
3088  {
3089  if (bCopy)
3090  {
3091  pDocShell->GetUndoManager()->AddUndoAction(
3092  std::make_unique<ScUndoCopyTab>(
3093  pDocShell, std::move(pSrcTabs), std::move(pDestTabs), std::move(pDestNames)));
3094  }
3095  else
3096  {
3097  pDocShell->GetUndoManager()->AddUndoAction(
3098  std::make_unique<ScUndoMoveTab>(
3099  pDocShell, std::move(pSrcTabs), std::move(pDestTabs), std::move(pTabNames), std::move(pDestNames)));
3100  }
3101  }
3102 
3103  SCTAB nNewTab = nDestTab;
3104  if (nNewTab == SC_TAB_APPEND)
3105  nNewTab = pDoc->GetTableCount()-1;
3106  else if (!bCopy && nTab<nDestTab)
3107  nNewTab--;
3108 
3109  SetTabNo( nNewTab, true );
3110 
3111  //#i29848# adjust references to data on the copied sheet
3112  if( bCopy )
3113  ScChartHelper::AdjustRangesOfChartsOnDestinationPage( pDoc, pDestDoc, nTab, nNewTab );
3114  }
3115 }
3116 
3117 void ScViewFunc::ShowTable( const std::vector<OUString>& rNames )
3118 {
3119  ScDocShell* pDocSh = GetViewData().GetDocShell();
3120  ScDocument& rDoc = pDocSh->GetDocument();
3121  bool bUndo(rDoc.IsUndoEnabled());
3122 
3123  std::vector<SCTAB> undoTabs;
3124  SCTAB nPos = 0;
3125 
3126  bool bFound(false);
3127 
3128  for (const OUString& aName : rNames)
3129  {
3130  if (rDoc.GetTable(aName, nPos))
3131  {
3132  rDoc.SetVisible( nPos, true );
3133  SetTabNo( nPos, true );
3134  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
3135  if (!bFound)
3136  bFound = true;
3137  if (bUndo)
3138  undoTabs.push_back(nPos);
3139  }
3140  }
3141  if (bFound)
3142  {
3143  if (bUndo)
3144  {
3145  pDocSh->GetUndoManager()->AddUndoAction( std::make_unique<ScUndoShowHideTab>( pDocSh, undoTabs, true ) );
3146  }
3147  pDocSh->PostPaint(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Extras);
3148  pDocSh->SetDocumentModified();
3149  }
3150 }
3151 
3152 void ScViewFunc::HideTable( const ScMarkData& rMark )
3153 {
3154  ScDocShell* pDocSh = GetViewData().GetDocShell();
3155  ScDocument& rDoc = pDocSh->GetDocument();
3156  bool bUndo(rDoc.IsUndoEnabled());
3157  SCTAB nVisible = 0;
3158  SCTAB nTabCount = rDoc.GetTableCount();
3159 
3160  SCTAB nTabSelCount = rMark.GetSelectCount();
3161 
3162  // check to make sure we won't hide all sheets. we need at least one visible at all times.
3163  for ( SCTAB i=0; i < nTabCount && nVisible <= nTabSelCount ; i++ )
3164  if (rDoc.IsVisible(i))
3165  ++nVisible;
3166 
3167  if (nVisible > nTabSelCount)
3168  {
3169  std::vector<SCTAB> undoTabs;
3170 
3171  // need to take a copy of selectedtabs since it is modified in the loop
3172  const ScMarkData::MarkedTabsType selectedTabs = rMark.GetSelectedTabs();
3173  for (const SCTAB& nTab : selectedTabs)
3174  {
3175  if (rDoc.IsVisible( nTab ))
3176  {
3177  rDoc.SetVisible( nTab, false );
3178  // Update views
3179  pDocSh->Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) );
3180  SetTabNo( nTab, true );
3181  // Store for undo
3182  if (bUndo)
3183  undoTabs.push_back(nTab);
3184  }
3185  }
3186  if (bUndo)
3187  {
3188  pDocSh->GetUndoManager()->AddUndoAction( std::make_unique<ScUndoShowHideTab>( pDocSh, undoTabs, false ) );
3189  }
3190 
3191  // Update views
3192  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
3193  pDocSh->PostPaint(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Extras);
3194  pDocSh->SetDocumentModified();
3195  }
3196 }
3197 
3198 void ScViewFunc::InsertSpecialChar( const OUString& rStr, const vcl::Font& rFont )
3199 {
3200  ScEditableTester aTester( this );
3201  if (!aTester.IsEditable())
3202  {
3203  ErrorMessage(aTester.GetMessageId());
3204  return;
3205  }
3206 
3207  const sal_Unicode* pChar = rStr.getStr();
3208  ScTabViewShell* pViewShell = GetViewData().GetViewShell();
3209  SvxFontItem aFontItem( rFont.GetFamilyType(),
3210  rFont.GetFamilyName(),
3211  rFont.GetStyleName(),
3212  rFont.GetPitch(),
3213  rFont.GetCharSet(),
3214  ATTR_FONT );
3215 
3216  // if string contains WEAK characters, set all fonts
3217  SvtScriptType nScript;
3218  ScDocument* pDoc = GetViewData().GetDocument();
3219  if ( pDoc->HasStringWeakCharacters( rStr ) )
3220  nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
3221  else
3222  nScript = pDoc->GetStringScriptType( rStr );
3223 
3224  SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, pViewShell->GetPool() );
3225  aSetItem.PutItemForScriptType( nScript, aFontItem );
3226  ApplyUserItemSet( aSetItem.GetItemSet() );
3227 
3228  while ( *pChar )
3229  pViewShell->TabKeyInput( KeyEvent( *(pChar++), vcl::KeyCode() ) );
3230 }
3231 
3232 void ScViewFunc::UpdateLineAttrs( SvxBorderLine& rLine,
3233  const SvxBorderLine* pDestLine,
3234  const SvxBorderLine* pSrcLine,
3235  bool bColor )
3236 {
3237  if ( pSrcLine && pDestLine )
3238  {
3239  if ( bColor )
3240  {
3241  rLine.SetColor ( pSrcLine->GetColor() );
3242  rLine.SetBorderLineStyle(pDestLine->GetBorderLineStyle());
3243  rLine.SetWidth ( pDestLine->GetWidth() );
3244  }
3245  else
3246  {
3247  rLine.SetColor ( pDestLine->GetColor() );
3248  rLine.SetBorderLineStyle(pSrcLine->GetBorderLineStyle());
3249  rLine.SetWidth ( pSrcLine->GetWidth() );
3250  }
3251  }
3252 }
3253 
3254 #define SET_LINE_ATTRIBUTES(LINE,BOXLINE) \
3255  pBoxLine = aBoxItem.Get##LINE(); \
3256  if ( pBoxLine ) \
3257  { \
3258  if ( pLine ) \
3259  { \
3260  UpdateLineAttrs( aLine, pBoxLine, pLine, bColorOnly ); \
3261  aBoxItem.SetLine( &aLine, BOXLINE ); \
3262  } \
3263  else \
3264  aBoxItem.SetLine( nullptr, BOXLINE ); \
3265  }
3266 
3267 void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine,
3268  bool bColorOnly )
3269 {
3270  // Not editable only due to a matrix? Attribute is ok anyhow.
3271  bool bOnlyNotBecauseOfMatrix;
3272  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
3273  {
3274  ErrorMessage(STR_PROTECTIONERR);
3275  return;
3276  }
3277 
3278  ScDocument* pDoc = GetViewData().GetDocument();
3279  ScMarkData aFuncMark( GetViewData().GetMarkData() ); // local copy for UnmarkFiltered
3280  ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
3281  ScDocShell* pDocSh = GetViewData().GetDocShell();
3282  const ScPatternAttr* pSelAttrs = GetSelectionPattern();
3283  const SfxItemSet& rSelItemSet = pSelAttrs->GetItemSet();
3284 
3285  const SfxPoolItem* pBorderAttr = nullptr;
3286  SfxItemState eItemState = rSelItemSet.GetItemState( ATTR_BORDER, true, &pBorderAttr );
3287 
3288  const SfxPoolItem* pTLBRItem = nullptr;
3289  SfxItemState eTLBRState = rSelItemSet.GetItemState( ATTR_BORDER_TLBR, true, &pTLBRItem );
3290 
3291  const SfxPoolItem* pBLTRItem = nullptr;
3292  SfxItemState eBLTRState = rSelItemSet.GetItemState( ATTR_BORDER_BLTR, true, &pBLTRItem );
3293 
3294  // any of the lines visible?
3295  if( (eItemState != SfxItemState::DEFAULT) || (eTLBRState != SfxItemState::DEFAULT) || (eBLTRState != SfxItemState::DEFAULT) )
3296  {
3297  // none of the lines don't care?
3298  if( (eItemState != SfxItemState::DONTCARE) && (eTLBRState != SfxItemState::DONTCARE) && (eBLTRState != SfxItemState::DONTCARE) )
3299  {
3300  std::unique_ptr<SfxItemSet> pOldSet(new SfxItemSet(
3301  *(pDoc->GetPool()),
3303  ATTR_PATTERN_END>{} ));
3304  std::unique_ptr<SfxItemSet> pNewSet(new SfxItemSet(
3305  *(pDoc->GetPool()),
3307  ATTR_PATTERN_END>{} ));
3308 
3309  SvxBorderLine aLine;
3310 
3311  if( pBorderAttr )
3312  {
3313  const SvxBorderLine* pBoxLine = nullptr;
3314  SvxBoxItem aBoxItem( *static_cast<const SvxBoxItem*>(pBorderAttr) );
3315  SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
3316 
3317  // here pBoxLine is used
3318  SET_LINE_ATTRIBUTES(Top,SvxBoxItemLine::TOP)
3319  SET_LINE_ATTRIBUTES(Bottom,SvxBoxItemLine::BOTTOM)
3320  SET_LINE_ATTRIBUTES(Left,SvxBoxItemLine::LEFT)
3321  SET_LINE_ATTRIBUTES(Right,SvxBoxItemLine::RIGHT)
3322 
3323  aBoxInfoItem.SetLine( aBoxItem.GetTop(), SvxBoxInfoItemLine::HORI );
3324  aBoxInfoItem.SetLine( aBoxItem.GetLeft(), SvxBoxInfoItemLine::VERT );
3325  aBoxInfoItem.ResetFlags(); // set Lines to Valid
3326 
3327  pOldSet->Put( *pBorderAttr );
3328  pNewSet->Put( aBoxItem );
3329  pNewSet->Put( aBoxInfoItem );
3330  }
3331 
3332  if( pTLBRItem && static_cast<const SvxLineItem*>(pTLBRItem)->GetLine() )
3333  {
3334  SvxLineItem aTLBRItem( *static_cast<const SvxLineItem*>(pTLBRItem) );
3335  UpdateLineAttrs( aLine, aTLBRItem.GetLine(), pLine, bColorOnly );
3336  aTLBRItem.SetLine( &aLine );
3337  pOldSet->Put( *pTLBRItem );
3338  pNewSet->Put( aTLBRItem );
3339  }
3340 
3341  if( pBLTRItem && static_cast<const SvxLineItem*>(pBLTRItem)->GetLine() )
3342  {
3343  SvxLineItem aBLTRItem( *static_cast<const SvxLineItem*>(pBLTRItem) );
3344  UpdateLineAttrs( aLine, aBLTRItem.GetLine(), pLine, bColorOnly );
3345  aBLTRItem.SetLine( &aLine );
3346  pOldSet->Put( *pBLTRItem );
3347  pNewSet->Put( aBLTRItem );
3348  }
3349 
3350  ApplyAttributes( pNewSet.get(), pOldSet.get() );
3351  }
3352  else // if ( eItemState == SfxItemState::DONTCARE )
3353  {
3354  aFuncMark.MarkToMulti();
3355  pDoc->ApplySelectionLineStyle( aFuncMark, pLine, bColorOnly );
3356  }
3357 
3358  ScRange aMarkRange;
3359  aFuncMark.GetMultiMarkArea( aMarkRange );
3360  SCCOL nStartCol = aMarkRange.aStart.Col();
3361  SCROW nStartRow = aMarkRange.aStart.Row();
3362  SCTAB nStartTab = aMarkRange.aStart.Tab();
3363  SCCOL nEndCol = aMarkRange.aEnd.Col();
3364  SCROW nEndRow = aMarkRange.aEnd.Row();
3365  SCTAB nEndTab = aMarkRange.aEnd.Tab();
3366  pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
3367  nEndCol, nEndRow, nEndTab,
3369 
3370  pDocSh->UpdateOle( &GetViewData() );
3371  pDocSh->SetDocumentModified();
3372  }
3373 }
3374 
3375 #undef SET_LINE_ATTRIBUTES
3376 
3378 {
3379  ScDocument* pDoc = GetViewData().GetDocument();
3380  sal_uLong nIndex = pDoc->AddValidationEntry(rNew); // for it there is no Undo
3381  SfxUInt32Item aItem( ATTR_VALIDDATA, nIndex );
3382 
3383  ApplyAttr( aItem ); // with Paint and Undo...
3384 }
3385 
3386 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SC_DLLPUBLIC OUString GetLinkDoc(SCTAB nTab) const
Definition: documen3.cxx:492
void FillTabMarked(SCTAB nSrcTab, const ScMarkData &rMark, InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink)
Definition: document.cxx:3298
std::shared_ptr< SfxDialogController > & GetController()
SC_DLLPUBLIC void InsertPageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
Definition: viewfun2.cxx:941
OUString GetLinkOpt(SCTAB nTab) const
Definition: documen3.cxx:506
#define SC_PF_TESTMERGE
Definition: docsh.hxx:75
void BeginDrawUndo()
Definition: documen9.cxx:58
void UpdateLinks() override
Definition: docsh6.cxx:321
constexpr double nPPTY
void UpdatePageBreaks(SCTAB nTab, const ScRange *pUserArea=nullptr)
Definition: document.cxx:6223
bool InsertTable(const OUString &rName, SCTAB nTabNr, bool bRecord=true)
Definition: viewfun2.cxx:2302
OUString GetColRowString() const
Create a human-readable string representation of the cell address.
Definition: address.cxx:2492
SC_DLLPUBLIC ScRefFlags ParseAny(const OUString &, const ScDocument *, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
Definition: address.cxx:1770
void MarkToSimple()
Definition: markdata.cxx:237
const std::vector< editeng::MisspellRanges > * GetAutoSpellData(SCCOL nPosX, SCROW nPosY)
Definition: gridwin.cxx:5718
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:2766
OpCode GetOuterFuncOpCode() const
ScAddress aStart
Definition: address.hxx:500
SC_DLLPUBLIC void ApplyPatternIfNumberformatIncompatible(const ScRange &rRange, const ScMarkData &rMark, const ScPatternAttr &rPattern, SvNumFormatType nNewType)
Definition: document.cxx:4796
bool bVisible
SC_DLLPUBLIC void SetScenario(SCTAB nTab, bool bFlag)
Definition: documen3.cxx:407
bool AdjustBlockHeight(bool bPaint=true, ScMarkData *pMarkData=nullptr)
Definition: viewfun2.cxx:113
void RemoveManualBreaks()
Definition: viewfun2.cxx:975
void SetSelectionFrameLines(const ::editeng::SvxBorderLine *pLine, bool bColorOnly)
Definition: viewfun2.cxx:3267
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1871
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: docsh3.cxx:450
SfxChildWindow * GetChildWindow(sal_uInt16)
SC_DLLPUBLIC ScLinkMode GetLinkMode(SCTAB nTab) const
Definition: documen3.cxx:485
#define STRING_SCAPP
Definition: global.hxx:54
const OUString & GetFamilyName() const
static void notifyAllViewsSheetGeomInvalidation(SfxViewShell *pForViewShell, bool bColumns, bool bRows, bool bSizes, bool bHidden, bool bFiltered, bool bGroups, SCTAB nCurrentTabIndex)
Emits a LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY for all views whose current tab is equal to nCurrentTa...
Definition: tabvwshc.cxx:556
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:262
void PostPaintGridAll()
Definition: docsh3.cxx:181
void MarkToMulti()
Definition: markdata.cxx:224
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:2357
FillDir
Definition: global.hxx:318
void SetPrintRanges(bool bEntireSheet, const OUString *pPrint, const OUString *pRepCol, const OUString *pRepRow, bool bAddPrint)
Definition: viewfun2.cxx:1014
void FillTab(InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink)
Definition: viewfun2.cxx:1609
std::unique_ptr< ContentProperties > pData
const OUString & GetStyleName() const
signed char sal_Int8
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
Definition: documen3.cxx:858
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
Definition: documen9.cxx:193
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:236
void ResetMark()
Definition: markdata.cxx:85
bool MergeCells(const ScCellMergeOption &rOption, bool bContents, bool bRecord, bool bApi, bool bEmptyMergedCells=false)
Definition: docfunc.cxx:4926
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, Color **ppColor, bool bUseStarFormat=false)
void GetCellSelection(std::vector< tools::Rectangle > &rLogicRects)
Get the cell selection, coordinates are in logic units.
Definition: gridwin.cxx:6303
const OUString & GetName() const
ScTokenArray * GetCode()
sal_uIntPtr sal_uLong
SC_DLLPUBLIC void ClearPrintRanges(SCTAB nTab)
Removes all print ranges.
Definition: document.cxx:6305
static ScAutoSum lcl_GetAutoSumForRowRange(ScDocument *pDoc, ScRangeList &rRangeList, const ScRange &rRange)
Definition: viewfun2.cxx:409
static ScAutoSum lcl_IsAutoSumData(ScDocument *pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, ScDirection eDir, SCCOLROW &nExtend)
Definition: viewfun2.cxx:262
ocSubTotal
ocOpen
sal_Int64 n
void ApplySelectionLineStyle(const ScMarkData &rMark, const ::editeng::SvxBorderLine *pLine, bool bColorOnly)
Definition: document.cxx:4884
void SetValidation(const ScValidationData &rNew)
Definition: viewfun2.cxx:3377
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:2388
void SetDocumentModified()
Definition: docsh.cxx:2819
const SfxItemSet & GetItemSet() const
void InsertTableLink(const OUString &rFile, const OUString &rFilter, const OUString &rOptions, const OUString &rTabName)
Definition: viewfun2.cxx:2611
void PostPaintExtras()
Definition: docsh3.cxx:196
void EnterBlock(const OUString &rString, const EditTextObject *pData)
Definition: viewfun2.cxx:850
void Solve(const ScSolveParam &rParam)
Definition: viewfun2.cxx:2165
SC_DLLPUBLIC void SetRepeatColRange(SCTAB nTab, std::unique_ptr< ScRange > pNew)
Definition: document.cxx:6323
constexpr TypedWhichId< SvxBoxInfoItem > ATTR_BORDER_INNER(151)
bool DeleteTable(SCTAB nTab, bool bRecord)
Definition: docfunc.cxx:3297
ScAddress aEnd
Definition: address.hxx:501
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:4538
void SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
Update the cell selection according to what handles have been dragged.
Definition: gridwin4.cxx:1491
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:104
void SetLine(const editeng::SvxBorderLine *pNew)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:988
#define SC_TAB_INSERTED
Definition: uiitems.hxx:76
void Invalidate(sal_uInt16 nId)
const SCCOL MAXCOLCOUNT
Definition: address.hxx:64
void TabChanged(bool bSameTabButMoved=false)
Called after moving, copying, inserting or deleting a sheet.
Definition: tabview5.cxx:277
ocCount
ocMin
bool IsLinked(SCTAB nTab) const
Definition: documen3.cxx:466
virtual SfxObjectShell * GetObjectShell() override
bool HasStringWeakCharacters(const OUString &rString)
Definition: documen6.cxx:51
const MarkedTabsType & GetSelectedTabs() const
Definition: markdata.hxx:98
RET_CANCEL
SC_DLLPUBLIC void SetVisible(SCTAB nTab, bool bVisible)
Definition: document.cxx:900
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:475
static void AdjustRangesOfChartsOnDestinationPage(const ScDocument *pSrcDoc, ScDocument *pDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab)
sal_uLong TransferTab(ScDocShell &rSrcDocShell, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew, bool bNotifyAndPaint)
Definition: docsh5.cxx:855
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:69
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5181
std::unique_ptr< ScPrintRangeSaver > CreatePrintRangeSaver() const
Definition: document.cxx:6335
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
Definition: documen6.cxx:76
void ConvertFormulaToValue()
Definition: viewfun2.cxx:1800
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4163
FontFamily GetFamilyType()
void SetClipParam(const ScClipParam &rParam)
Definition: document.cxx:2559
#define SC_DOC_NEW
Definition: document.hxx:238
SfxApplication * SfxGetpApp()
bool RenameTable(const OUString &rName, SCTAB nTabNr)
Definition: viewfun2.cxx:2565
void ResetAutoSpell()
Definition: gridwin.cxx:5697
Internal use only (d&d undo): do not delete caption objects of cell notes.
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6063
void GetMarkArea(ScRange &rRange) const
Definition: markdata.cxx:112
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2805
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:2315
void logEvent(const EventDescription &rDescription)
static bool lcl_extendMergeRange(ScCellMergeOption &rOption, const ScRange &rRange)
Definition: viewfun2.cxx:1281
sal_uInt16 sal_Unicode
static sal_Int8 GetSubTotal(const OpCode eCode)
Definition: viewfun2.cxx:456
RET_YES
static bool lcl_FindNextSumEntryInColumn(ScDocument *pDoc, SCCOL nCol, SCROW &nRow, SCTAB nTab, SCCOLROW &nExtend, SCROW nMinRow)
Definition: viewfun2.cxx:332
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:1406
void UpdateOle(const ScViewData *pViewData, bool bSnapSize=false)
Definition: docsh6.cxx:152
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:876
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:313
SCTAB GetSelectCount() const
Definition: markdata.cxx:195
bool IsMultiMarked() const
Definition: markdata.hxx:83
SvxSearchCellType GetCellType() const
OpCode
SfxFrame & GetFrame() const
int nCount
FillDateCmd
Definition: global.hxx:343
void ConvertFormulaToValue(const ScRange &rRange, bool bInteraction)
Definition: docfunc.cxx:5717
void TransliterateText(TransliterationFlags nType)
Definition: viewfun2.cxx:1811
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:2075
#define SC_AUTOSUM_MAXCOUNT
Definition: viewfun2.cxx:299
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
ScDocShell * GetDocShell()
Definition: tablink.hxx:91
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:259
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1144
void UpdateScriptTypes(const ScAddress &rPos, SCCOL nColSize, SCROW nRowSize)
Definition: document10.cxx:334
void AutoFormat(sal_uInt16 nFormatNo)
Definition: viewfun2.cxx:1853
bool RemoveMerge()
Definition: viewfun2.cxx:1307
bool InsideVisibleRange(SCCOL nPosX, SCROW nPosY)
Definition: gridwin.cxx:5729
ScFormulaCell * mpFormula
Definition: cellvalue.hxx:111
SCTAB Tab() const
Definition: address.hxx:271
void SetRow(SCROW nRowP)
Definition: address.hxx:275
bool SearchAndReplace(const SvxSearchItem *pSearchItem, bool bAddUndo, bool bIsApi)
Definition: viewfun2.cxx:1871
#define SC_TAB_DELETED
Definition: uiitems.hxx:77
ScDocument * GetDocument() const
Definition: viewdata.cxx:859
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:29
static sal_Unicode GetNativeSymbolChar(OpCode eOp)
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4737
void SetCol(SCCOL nColP)
Definition: address.hxx:279
const char * sName
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:166
TransliterationFlags
SC_DLLPUBLIC void DeletePageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
Definition: viewfun2.cxx:958
SfxItemPool & GetPool() const
sal_Int32 GetStartPointX() const
bool AutoFormat(const ScRange &rRange, const ScMarkData *pTabMark, sal_uInt16 nFormatNo, bool bApi)
Definition: docfunc.cxx:4198
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, const OUString &rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
OutputDevice * GetDevice() const
Definition: sizedev.hxx:40
static ScAutoSum lcl_GetAutoSumForColumnRange(ScDocument *pDoc, ScRangeList &rRangeList, const ScRange &rRange)
Definition: viewfun2.cxx:362
bool empty() const
Definition: rangelst.hxx:89
ocSep
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1904
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:30
void SetMarkArea(const ScRange &rRange)
Definition: markdata.cxx:97
ScPasteFunc
Definition: global.hxx:189
void SetTab(SCTAB nTabP)
Definition: address.hxx:283
SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: documen3.cxx:418
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1062
const editeng::SvxBorderLine * GetTop() const
static void UpdateLineAttrs(::editeng::SvxBorderLine &rLine, const ::editeng::SvxBorderLine *pDestLine, const ::editeng::SvxBorderLine *pSrcLine, bool bColor)
Definition: viewfun2.cxx:3232
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:875
T * get() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
bool IsChartListenerCollectionNeedsUpdate() const
Definition: document.hxx:2152
void UseScenario(const OUString &rName)
Definition: viewfun2.cxx:2290
void ShowTable(const std::vector< OUString > &rNames)
Definition: viewfun2.cxx:3117
Parameter for data table aka multiple operations.
Definition: paramisc.hxx:46
SvtScriptType
FillCmd
Definition: global.hxx:326
FontPitch GetPitch()
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:559
const SCTAB SC_TAB_APPEND
Definition: address.hxx:84
bool IsMarked() const
Definition: markdata.hxx:82
const editeng::SvxBorderLine * GetLeft() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
SvxSearchCmd GetCommand() const
ScRange getSingleRange(SCTAB nTab) const
SC_DLLPUBLIC void SetActiveScenario(SCTAB nTab, bool bActive)
Definition: documen3.cxx:863
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:3230
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:304
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:477
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2618
sal_Int16 SCCOL
Definition: types.hxx:22
void GetAutoFormatData(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData &rData)
Definition: documen3.cxx:1176
InsertDeleteFlags
Definition: global.hxx:158
#define SC_TAB_HIDDEN
Definition: uiitems.hxx:80
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
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
Definition: document.cxx:4268
bool TestMergeCells()
Definition: viewfun2.cxx:1123
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:449
size_t size() const
Definition: rangelst.hxx:90
void SetCommand(SvxSearchCmd nNewCommand)
void IncRow(SCROW nDelta=1)
Definition: address.hxx:300
void SetPrintZoom(SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages)
Definition: docsh4.cxx:1601
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
void SetLink(SCTAB nTab, ScLinkMode nMode, const OUString &rDoc, const OUString &rFilter, const OUString &rOptions, const OUString &rTabName, sal_uLong nRefreshDelay)
Definition: documen3.cxx:527
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:1256
ocMax
OUString GetLinkFlt(SCTAB nTab) const
Definition: documen3.cxx:499
void SetAutoSpellData(SCCOL nPosX, SCROW nPosY, const std::vector< editeng::MisspellRanges > *pRanges)
Definition: gridwin.cxx:5707
void UseScenario(SCTAB nTab, const OUString &rName, bool bRecord=true)
Definition: docsh5.cxx:660
iterator end()
Definition: markdata.cxx:954
#define SET_LINE_ATTRIBUTES(LINE, BOXLINE)
Definition: viewfun2.cxx:3254
PaintArea
bool IsEditable() const
Definition: editable.hxx:84
bool hasNumeric() const
Definition: cellvalue.cxx:622
bool IsBlockEmpty(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes=false) const
Definition: document.cxx:5298
bool IsAllTables() const
void GetSearchAndReplaceStart(const SvxSearchItem &rSearchItem, SCCOL &rCol, SCROW &rRow)
Definition: documen3.cxx:1190
SC_DLLPUBLIC void AddPrintRange(SCTAB nTab, const ScRange &rNew)
Adds a new print ranges.
Definition: document.cxx:6311
const SCTAB MAXTAB
Definition: address.hxx:71
void RemoveManualBreaks(SCTAB nTab)
Definition: document.cxx:6229
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:99
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5570
bool TabOp(const ScRange &rRange, const ScMarkData *pTabMark, const ScTabOpParam &rParam, bool bRecord, bool bApi)
Definition: docfunc.cxx:4398
const std::shared_ptr< const SfxFilter > & GetFilter() const
void PostDataChanged()
Definition: docsh3.cxx:91
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:2267
SCCOL Col() const
Definition: address.hxx:267
bool HasLink(const OUString &rDoc, const OUString &rFilter, const OUString &rOptions) const
Definition: documen3.cxx:535
SC_DLLPUBLIC void SetRepeatRowRange(SCTAB nTab, std::unique_ptr< ScRange > pNew)
Definition: document.cxx:6329
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:5504
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:2588
virtual void ClearPageView() override
void InsertAreaLink(const OUString &rFile, const OUString &rFilter, const OUString &rOptions, const OUString &rSource)
Definition: viewfun2.cxx:2598
ScModelObj * getMustPropagateChangesModel(const ScDocShell &rDocShell)
Definition: docsh.hxx:469
bool IsError() const
Definition: tablink.cxx:578
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:449
#define SC_TABS_DELETED
Definition: uiitems.hxx:82
void SetPrintZoom(sal_uInt16 nScale)
Definition: viewfun2.cxx:999
bool UnmergeCells(const ScRange &rRange, bool bRecord, ScUndoRemoveMerge *pUndoRemoveMerge)
Definition: docfunc.cxx:5043
CellType meType
Definition: cellvalue.hxx:106
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
Definition: documen3.cxx:429
SC_DLLPUBLIC sal_uLong AddValidationEntry(const ScValidationData &rNew)
Definition: documen4.cxx:716
void FillAuto(FillDir eDir, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount)
Definition: viewfun2.cxx:1429
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
iterator begin()
Definition: markdata.cxx:949
sal_Int32 SCROW
Definition: types.hxx:18
SC_DLLPUBLIC void PutInOrder()
Definition: address.cxx:1577
#define SC_PF_LINES
Definition: docsh.hxx:74
static void notifyAllViewsHeaderInvalidation(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:499
bool MergeCells(bool bApi, bool &rDoContents, bool bCenter)
Definition: viewfun2.cxx:1140
static SfxViewFrame * Current()
const editeng::SvxBorderLine * GetLine() const
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow)
Definition: viewfun2.cxx:191
SfxItemState
ocAverage
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:413
ScDrawView * GetScDrawView()
Definition: tabview.hxx:340
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:81
SvBaseLink * pLink
void FillResults(ScDocument *pDoc, const ScRangeList &rMatchedRanges, bool bCellNotes)
void FindAreaPos(SCCOL &rCol, SCROW &rRow, SCTAB nTab, ScMoveDirection eDirection) const
Definition: document.cxx:6090
static ScAutoSum lcl_SeekAutoSumData(ScDocument *pDoc, SCCOL &nCol, SCROW &nRow, SCTAB nTab, ScDirection eDir, SCCOLROW &nExtend)
Definition: viewfun2.cxx:301
SCTAB MakeScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags, ScMarkData &rMark, bool bRecord=true)
Definition: docsh5.cxx:785
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:520
const OUString & GetSearchString() const
sal_Int32 GetStartPointY() const
RET_OK
const ScSheetEvents * GetSheetEvents(SCTAB nTab) const
Definition: documen3.cxx:640
SCTAB GetLastSelected() const
Definition: markdata.cxx:209
bool SetTabBgColor(const Color &rColor, SCTAB nTabNr)
Definition: viewfun2.cxx:2578
void EnterAutoSum(const ScRangeList &rRangeList, bool bSubTotal, const ScAddress &rAddr, const OpCode eCode)
Definition: viewfun2.cxx:583
static void UnmarkFiltered(ScMarkData &rMark, const ScDocument *pDoc)
Definition: viewutil.cxx:223
bool IsInVBAMode() const
Definition: document.cxx:6493
SC_DLLPUBLIC bool HasData(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: documen5.cxx:525
virtual short run()
void FillSimple(FillDir eDir)
Definition: viewfun2.cxx:1357
void * p
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
SC_DLLPUBLIC OUString GetLinkTab(SCTAB nTab) const
Definition: documen3.cxx:513
constexpr sal_uInt16 ATTR_PATTERN_END(155)
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
const char * pChar
bool IsAutoSpell() const
Definition: docoptio.hxx:54
bool TabKeyInput(const KeyEvent &rKEvt)
Definition: tabvwsh4.cxx:1160
SC_DLLPUBLIC void UpdateChartListenerCollection()
Definition: documen5.cxx:569
SC_DLLPUBLIC void SetPrintEntireSheet(SCTAB nTab)
Marks the specified sheet to be printed completely.
Definition: document.cxx:6317
SC_DLLPUBLIC bool DeleteTab(SCTAB nTab)
Definition: document.cxx:672
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:444
void NotifyIfChangesListeners(const ScDocShell &rDocShell, const ScRange &rRange, const OUString &rType=OUString("cell-change"))
Definition: docsh.hxx:485
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:993
SC_DLLPUBLIC ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1880
void ImportTables(ScDocShell *pSrcShell, SCTAB nCount, const SCTAB *pSrcTabs, bool bLink, SCTAB nTab)
Definition: viewfun2.cxx:2645
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
bool SearchAndReplace(const SvxSearchItem &rSearchItem, SCCOL &rCol, SCROW &rRow, SCTAB &rTab, const ScMarkData &rMark, ScRangeList &rMatchedRanges, OUString &rUndoStr, ScDocument *pUndoDoc=nullptr)
Definition: documen3.cxx:1276
sal_uInt32 GetValue() const
ScAddress aRefFormulaCell
Definition: paramisc.hxx:28
bool MoveTable(SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord)
Definition: docsh5.cxx:902
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
Definition: document.cxx:907
void InitRangeRel(const ScDocument *pDoc, const ScRange &rRange, const ScAddress &rPos)
Definition: refdata.hxx:135
bool IsUndoEnabled() const
Definition: document.hxx:1534
ScDirection
Definition: global.hxx:351
const OUString & GetCodeName() const
Definition: document.hxx:607
void GetMultiMarkArea(ScRange &rRange) const
Definition: markdata.cxx:117
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:218
bool NeedsObject() const
Definition: editutil.hxx:99
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2558
void InsertSpecialChar(const OUString &rStr, const vcl::Font &rFont)
Definition: viewfun2.cxx:3198
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:184
bool TestRemoveMerge()
Definition: viewfun2.cxx:1268
static bool lcl_FindNextSumEntryInRow(ScDocument *pDoc, SCCOL &nCol, SCROW nRow, SCTAB nTab, SCCOLROW &nExtend, SCCOL nMinCol)
Definition: viewfun2.cxx:347
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:5480
ScAutoFormatData * CreateAutoFormatData()
Definition: viewfun2.cxx:1832
void FillCrossDblClick()
Downward fill of selected cell(s) by double-clicking cross-hair cursor.
Definition: viewfun2.cxx:1689
void ExtendScenario()
Definition: viewfun2.cxx:2272
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:215
std::set< SCTAB > MarkedTabsType
Definition: markdata.hxx:46
void VBA_DeleteModule(ScDocShell &rDocSh, const OUString &sModuleName)
Definition: docfunc.cxx:3218
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)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
::std::vector< ScUndoTabColorInfo > List
Definition: tabbgcolor.hxx:37
rtl_TextEncoding GetCharSet() const
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:23
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:42
void HideTable(const ScMarkData &rMark)
Definition: viewfun2.cxx:3152
void AdjustPrintZoom()
Definition: viewfun2.cxx:1006
void MakeScenario(const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: viewfun2.cxx:2251
void TabOp(const ScTabOpParam &rParam, bool bRecord=true)
Definition: viewfun2.cxx:2238
ocSum
static SC_DLLPUBLIC const SvxSearchItem & GetSearchItem()
Definition: global.cxx:214
SfxMedium * GetMedium() const