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