LibreOffice Module sc (master) 1
documen2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <scextopt.hxx>
21#include <autonamecache.hxx>
22
23#include <o3tl/safeint.hxx>
24#include <osl/thread.h>
25#include <svx/xtable.hxx>
26#include <sfx2/bindings.hxx>
27#include <sfx2/objsh.hxx>
28#include <sfx2/docfile.hxx>
29#include <sfx2/printer.hxx>
30#include <svl/asiancfg.hxx>
31#include <vcl/virdev.hxx>
33#include <tools/urlobj.hxx>
34#include <rtl/crc.h>
35#include <basic/basmgr.hxx>
37#include <sal/log.hxx>
38#include <osl/diagnose.h>
40
41#include <scmod.hxx>
42#include <document.hxx>
43#include <table.hxx>
44#include <patattr.hxx>
45#include <rangenam.hxx>
46#include <dbdata.hxx>
47#include <chartlock.hxx>
48#include <rechead.hxx>
49#include <global.hxx>
50#include <bcaslot.hxx>
51#include <adiasync.hxx>
52#include <addinlis.hxx>
53#include <chartlis.hxx>
54#include <markdata.hxx>
55#include <validat.hxx>
56#include <detdata.hxx>
57#include <defaultsoptions.hxx>
58#include <ddelink.hxx>
59#include <chgtrack.hxx>
60#include <chgviset.hxx>
61#include <editutil.hxx>
62#include <hints.hxx>
63#include <dpobject.hxx>
64#include <scrdata.hxx>
65#include <poolhelp.hxx>
66#include <unoreflist.hxx>
67#include <listenercalls.hxx>
68#include <recursionhelper.hxx>
69#include <lookupcache.hxx>
70#include <rangecache.hxx>
71#include <externalrefmgr.hxx>
72#include <viewdata.hxx>
73#include <viewutil.hxx>
74#include <tabprotection.hxx>
75#include <formulaparserpool.hxx>
76#include <clipparam.hxx>
77#include <macromgr.hxx>
78#include <formulacell.hxx>
79#include <clipcontext.hxx>
80#include <refupdatecontext.hxx>
82#include <scopetools.hxx>
83#include <documentlinkmgr.hxx>
84#include <interpre.hxx>
86#include <docsh.hxx>
87#include <clipoptions.hxx>
88#include <listenercontext.hxx>
89#include <datamapper.hxx>
90#include <drwlayer.hxx>
92#include <dociter.hxx>
93#include <config_features.h>
94
95using namespace com::sun::star;
96
98
100{
101#if HAVE_FEATURE_JUMBO_SHEETS
102 bool jumboSheets = false;
103 if( SC_MOD())
104 jumboSheets = SC_MOD()->GetDefaultsOptions().GetInitJumboSheets();
105 else
106 assert( getenv("LO_TESTNAME") != nullptr ); // in unittests
107 if (jumboSheets)
109 else
110#endif
111 return ScSheetLimits(MAXCOL, MAXROW);
112}
113
115 mpCellStringPool(std::make_shared<svl::SharedStringPool>(ScGlobal::getCharClass())),
116 mpDocLinkMgr(new sc::DocumentLinkManager(pDocShell)),
117 mbFormulaGroupCxtBlockDiscard(false),
118 maCalcConfig( ScInterpreter::GetGlobalConfig()),
119 mpUndoManager( nullptr ),
120 mpShell( pDocShell ),
121 mpPrinter( nullptr ),
122 mpVirtualDevice_100th_mm( nullptr ),
123 pFormatExchangeList( nullptr ),
124 mxSheetLimits(new ScSheetLimits(ScSheetLimits::CreateDefault())),
125 pFormulaTree( nullptr ),
126 pEOFormulaTree( nullptr ),
127 pFormulaTrack( nullptr ),
128 pEOFormulaTrack( nullptr ),
129 pPreviewCellStyle( nullptr ),
130 maPreviewSelection(*mxSheetLimits),
131 nUnoObjectId( 0 ),
132 nRangeOverflowType( 0 ),
133 aCurTextWidthCalcPos(MaxCol(),0,0),
134 aTrackIdle("sc ScDocument Track Idle"),
135 nFormulaCodeInTree(0),
136 nXMLImportedFormulaCount( 0 ),
137 nInterpretLevel(0),
138 nMacroInterpretLevel(0),
139 nInterpreterTableOpLevel(0),
140 maInterpreterContext( *this, nullptr ),
141 mxScSortedRangeCache(new ScSortedRangeCacheMap),
142 nFormulaTrackCount(0),
143 eHardRecalcState(HardRecalcState::OFF),
144 nVisibleTab( 0 ),
145 nPosLeft( 0 ),
146 nPosTop( 0 ),
147 eLinkMode(LM_UNKNOWN),
149 bAutoCalcShellDisabled( false ),
150 bForcedFormulaPending( false ),
151 bCalculatingFormulaTree( false ),
152 bIsClip( eMode == SCDOCMODE_CLIP ),
153 bIsUndo( eMode == SCDOCMODE_UNDO ),
154 bIsFunctionAccess( eMode == SCDOCMODE_FUNCTIONACCESS ),
155 bIsVisible( false ),
156 bIsEmbedded( false ),
157 bInsertingFromOtherDoc( false ),
158 bLoadingMedium( false ),
159 bImportingXML( false ),
160 bCalcingAfterLoad( false ),
161 bNoListening( false ),
162 mbIdleEnabled(true),
163 bInLinkUpdate( false ),
164 bChartListenerCollectionNeedsUpdate( false ),
165 bHasForcedFormulas( false ),
166 bInDtorClear( false ),
167 bExpandRefs( false ),
168 bDetectiveDirty( false ),
169 bDelayedDeletingBroadcasters( false ),
170 bLinkFormulaNeedingCheck( false ),
171 nAsianCompression(CharCompressType::Invalid),
172 nAsianKerning(SC_ASIANKERNING_INVALID),
173 bPastingDrawFromOtherDoc( false ),
174 nInDdeLinkUpdate( 0 ),
175 bInUnoBroadcast( false ),
176 bInUnoListenerCall( false ),
177 nAdjustHeightLock(0),
178 eGrammar( formula::FormulaGrammar::GRAM_NATIVE ),
179 bStyleSheetUsageInvalid( true ),
180 mbUndoEnabled( true ),
181 mbExecuteLinkEnabled( true ),
182 mbChangeReadOnlyEnabled( false ),
183 mbStreamValidLocked( false ),
184 mbUserInteractionEnabled(true),
185 mnNamedRangesLockCount(0),
186 mbEmbedFonts(false),
187 mbEmbedUsedFontsOnly(false),
188 mbEmbedFontScriptLatin(true),
189 mbEmbedFontScriptAsian(true),
190 mbEmbedFontScriptComplex(true),
191 mnImagePreferredDPI(0),
192 mbTrackFormulasPending(false),
193 mbFinalTrackFormulas(false),
194 mbDocShellRecalc(false),
195 mbLayoutStrings(false),
196 mnMutationGuardFlags(0)
197{
199 aCurTextWidthCalcPos = { MaxCol(), 0, 0 };
200
202
203 eSrcSet = osl_getThreadTextEncoding();
204
205 /* TODO: for SCDOCMODE_FUNCTIONACCESS it might not even be necessary to
206 * have all of these available. */
208 {
209 mxPoolHelper = new ScPoolHelper( *this );
210 if (!utl::ConfigManager::IsFuzzing()) //just too slow
211 pBASM.reset( new ScBroadcastAreaSlotMachine( this ) );
214 }
215 else
216 {
217 pChartListenerCollection = nullptr;
218 }
219 pDBCollection.reset( new ScDBCollection(*this) );
220 pSelectionAttr = nullptr;
225 // languages for a visible document are set by docshell later (from options)
227
228 aTrackIdle.SetInvokeHandler( LINK( this, ScDocument, TrackTimeHdl ) );
229}
230
232{
234}
235
237{
239}
240
242{
243 return *mpDocLinkMgr;
244}
245
247{
248 return const_cast<ScDocument*>(this)->GetDocLinkManager();
249}
250
252{
253 OSL_PRECOND(
256 "ScDocument::SetStorageGrammar: wrong storage grammar");
257
258 eStorageGrammar = eGram;
259}
260
262{
263 // called from view ctor - only for a visible document,
264 // each new sheet's RTL flag is initialized from the locale
265 bIsVisible = bSet;
266}
267
269{
270 const ScDocument* pThis = this;
271 sal_uInt32 nCrc = rtl_crc32( 0, &pThis, sizeof(ScDocument*) );
272 // the this pointer only might not be sufficient
273 nCrc = rtl_crc32( nCrc, &mpShell, sizeof(SfxObjectShell*) );
274 return nCrc;
275}
276
278{
279 if (!pChangeTrack)
280 {
281 pChangeTrack.reset( new ScChangeTrack( *this ) );
282 if (mpShell)
284 }
285}
286
288{
289 if (pChangeTrack && mpShell)
291 pChangeTrack.reset();
292}
293
294void ScDocument::SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack )
295{
296 OSL_ENSURE( &pTrack->GetDocument() == this, "SetChangeTrack: different documents" );
297 if ( !pTrack || pTrack == pChangeTrack || &pTrack->GetDocument() != this )
298 return ;
300 pChangeTrack = std::move(pTrack);
301}
302
303IMPL_LINK_NOARG(ScDocument, TrackTimeHdl, Timer *, void)
304{
305 if ( ScDdeLink::IsInUpdate() ) // do not nest
306 {
307 aTrackIdle.Start(); // try again later
308 }
309 else if (mpShell) // execute
310 {
311 TrackFormulas();
312 mpShell->Broadcast( SfxHint( SfxHintId::ScDataChanged ) );
313
314 if (!mpShell->IsModified())
315 {
316 mpShell->SetModified();
317 SfxBindings* pBindings = GetViewBindings();
318 if (pBindings)
319 {
320 pBindings->Invalidate( SID_SAVEDOC );
321 pBindings->Invalidate( SID_DOC_MODIFIED );
322 }
323 }
324 }
325}
326
328{
329 bExpandRefs = bVal;
330}
331
333{
334 if (!aTrackIdle.IsActive()) // do not postpone for forever
336}
337
339{
340 if (!bIsClip)
341 return;
342
344}
345
347{
348 OSL_PRECOND( !bInLinkUpdate, "bInLinkUpdate in dtor" );
349
350 // Join any pending(recalc) threads in global threadpool
352
353 bInDtorClear = true;
354
355 // first of all disable all refresh timers by deleting the control
357 { // To be sure there isn't anything running do it with a protector,
358 // this ensures also that nothing needs the control anymore.
360 pRefreshTimerControl.reset();
361 }
362
363 mxFormulaParserPool.reset();
364 // Destroy the external ref mgr instance here because it has a timer
365 // which needs to be stopped before the app closes.
366 pExternalRefMgr.reset();
367
370 pChartListenerCollection.reset(); // before pBASM because of potential Listener!
371
372 ClearLookupCaches(); // before pBASM because of listeners
373
374 // destroy BroadcastAreas first to avoid un-needed Single-EndListenings of Formula-Cells
375 pBASM.reset(); // BroadcastAreaSlotMachine
376
377 pUnoBroadcaster.reset(); // broadcasts SfxHintId::Dying again
378
379 pUnoRefUndoList.reset();
380 pUnoListenerCalls.reset();
381
382 Clear( true ); // true = from destructor (needed for SdrModel::ClearModel)
383
384 pValidationList.reset();
385 pRangeName.reset();
386 pDBCollection.reset();
387 pSelectionAttr.reset();
388 apTemporaryChartLock.reset();
392 pConsolidateDlgData.reset();
393 pClipData.reset();
394 pDetOpList.reset(); // also deletes entries
395 pChangeTrack.reset();
396 mpEditEngine.reset();
397 mpNoteEngine.reset();
398 pChangeViewSettings.reset(); // and delete
400
401 pDPCollection.reset();
402 mpAnonymousDBData.reset();
403
404 // delete the EditEngine before destroying the mxPoolHelper
405 pCacheFieldEditEngine.reset();
406
407 if ( mxPoolHelper.is() && !bIsClip && !bIsUndo)
408 mxPoolHelper->SourceDocumentGone();
409 mxPoolHelper.clear();
410
411 pScriptTypeData.reset();
414
415 pPreviewFont.reset();
416 SAL_WARN_IF( pAutoNameCache, "sc.core", "AutoNameCache still set in dtor" );
417
418 mpFormulaGroupCxt.reset();
419 // Purge unused items if the string pool will be still used (e.g. by undo history).
420 if(mpCellStringPool.use_count() > 1)
421 {
422 // Calling purge() may be somewhat expensive with large documents, so
423 // try to delay and compress it for temporary documents.
424 if(IsClipOrUndo())
426 else
427 mpCellStringPool->purge();
428 }
429 mpCellStringPool.reset();
430
431 assert( pDelayedFormulaGrouping == nullptr );
432 assert( pDelayedStartListeningFormulaCells.empty());
433}
434
436{
437 OSL_ENSURE(bIsClip, "InitClipPtrs and not bIsClip");
438
440
441 pValidationList.reset();
442
443 Clear();
444
445 SharePooledResources(pSourceDoc);
446
447 // conditional Formats / validations
448 // TODO: Copy Templates?
449 const ScValidationDataList* pSourceValid = pSourceDoc->pValidationList.get();
450 if ( pSourceValid )
451 pValidationList.reset(new ScValidationDataList(*this, *pSourceValid));
452
453 // store Links in Stream
454 pClipData.reset();
455 if (pSourceDoc->GetDocLinkManager().hasDdeLinks())
456 {
457 pClipData.reset( new SvMemoryStream );
458 pSourceDoc->SaveDdeLinks(*pClipData);
459 }
460
461 // Options pointers exist (ImplCreateOptions) for any document.
462 // Must be copied for correct results in OLE objects (#i42666#).
463 SetDocOptions( pSourceDoc->GetDocOptions() );
464 SetViewOptions( pSourceDoc->GetViewOptions() );
465}
466
468{
470 return mxPoolHelper->GetFormTable();
471}
472
474{
475 return mxPoolHelper->GetEditPool();
476}
477
479{
480 return mxPoolHelper->GetEnginePool();
481}
482
484{
485 if ( !mpEditEngine )
486 {
488 mpEditEngine->SetUpdateLayout( false );
489 mpEditEngine->EnableUndo( false );
490 mpEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
492 }
493 return *mpEditEngine;
494}
495
497{
498 if ( !mpNoteEngine )
499 {
502 mpNoteEngine->SetUpdateLayout( false );
503 mpNoteEngine->EnableUndo( false );
504 mpNoteEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
506 const SfxItemSet& rItemSet = GetDefPattern()->GetItemSet();
507 SfxItemSet aEEItemSet( mpNoteEngine->GetEmptyItemSet() );
508 ScPatternAttr::FillToEditItemSet( aEEItemSet, rItemSet );
509 mpNoteEngine->SetDefaults( std::move(aEEItemSet) ); // edit engine takes ownership
510 }
511 return *mpNoteEngine;
512}
513
514void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks )
515{
516 if (bIsClip)
517 {
518 InitClipPtrs(pSourceDoc);
519
520 for (SCTAB i = 0; i < static_cast<SCTAB>(pSourceDoc->maTabs.size()); i++)
521 if (pSourceDoc->maTabs[i])
522 if (!pMarks || pMarks->GetTableSelect(i))
523 {
524 OUString aString = pSourceDoc->maTabs[i]->GetName();
525 if ( i < static_cast<SCTAB>(maTabs.size()) )
526 {
527 maTabs[i].reset( new ScTable(*this, i, aString) );
528
529 }
530 else
531 {
532 if( i > static_cast<SCTAB>(maTabs.size()) )
533 {
534 maTabs.resize(i);
535 }
536 maTabs.emplace_back(new ScTable(*this, i, aString));
537 }
538 maTabs[i]->SetLayoutRTL( pSourceDoc->maTabs[i]->IsLayoutRTL() );
539 }
540 }
541 else
542 {
543 OSL_FAIL("ResetClip");
544 }
545}
546
547void ScDocument::ResetClip( ScDocument* pSourceDoc, SCTAB nTab )
548{
549 if (bIsClip)
550 {
551 InitClipPtrs(pSourceDoc);
552 if (nTab >= static_cast<SCTAB>(maTabs.size()))
553 {
554 maTabs.resize(nTab+1);
555 }
556 maTabs[nTab].reset( new ScTable(*this, nTab, "baeh") );
557 if (nTab < static_cast<SCTAB>(pSourceDoc->maTabs.size()) && pSourceDoc->maTabs[nTab])
558 maTabs[nTab]->SetLayoutRTL( pSourceDoc->maTabs[nTab]->IsLayoutRTL() );
559 }
560 else
561 {
562 OSL_FAIL("ResetClip");
563 }
564}
565
567{
568 bool bExtras = !bIsUndo; // Column-Widths, Row-Heights, Flags
569 if (o3tl::make_unsigned(nTab) >= maTabs.size())
570 maTabs.resize(nTab+1);
571
572 if (!maTabs[nTab])
573 maTabs[nTab].reset( new ScTable(*this, nTab, "temp", bExtras, bExtras) );
574}
575
577{
578 if (!TableExists(rPos.Tab()))
579 return ScRefCellValue(); // empty
580
581 return maTabs[rPos.Tab()]->GetRefCellValue(rPos.Col(), rPos.Row());
582}
583
585{
586 if (!TableExists(rPos.Tab()))
587 return ScRefCellValue(); // empty
588
589 return maTabs[rPos.Tab()]->GetRefCellValue(rPos.Col(), rPos.Row(), rBlockPos);
590}
591
593{
594 return *mpCellStringPool;
595}
596
598{
599 return *mpCellStringPool;
600}
601
602bool ScDocument::GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
603 bool bNotes) const
604{
605 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
606 {
607 bool bAny = maTabs[nTab]->GetPrintArea( rEndCol, rEndRow, bNotes, /*bCalcHiddens*/false);
608 if (mpDrawLayer)
609 {
610 ScRange aDrawRange(0,0,nTab, MaxCol(),MaxRow(),nTab);
611 if (DrawGetPrintArea( aDrawRange, true, true ))
612 {
613 if (aDrawRange.aEnd.Col()>rEndCol) rEndCol=aDrawRange.aEnd.Col();
614 if (aDrawRange.aEnd.Row()>rEndRow) rEndRow=aDrawRange.aEnd.Row();
615 bAny = true;
616 }
617 }
618 return bAny;
619 }
620
621 rEndCol = 0;
622 rEndRow = 0;
623 return false;
624}
625
626bool ScDocument::GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
627 SCCOL& rEndCol ) const
628{
629 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
630 {
631 bool bAny = maTabs[nTab]->GetPrintAreaHor( nStartRow, nEndRow, rEndCol );
632 if (mpDrawLayer)
633 {
634 ScRange aDrawRange(0,nStartRow,nTab, MaxCol(),nEndRow,nTab);
635 if (DrawGetPrintArea( aDrawRange, true, false ))
636 {
637 if (aDrawRange.aEnd.Col()>rEndCol) rEndCol=aDrawRange.aEnd.Col();
638 bAny = true;
639 }
640 }
641 return bAny;
642 }
643
644 rEndCol = 0;
645 return false;
646}
647
648bool ScDocument::GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
649 SCROW& rEndRow, bool bNotes ) const
650{
651 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
652 {
653 bool bAny = maTabs[nTab]->GetPrintAreaVer( nStartCol, nEndCol, rEndRow, bNotes );
654 if (mpDrawLayer)
655 {
656 ScRange aDrawRange(nStartCol,0,nTab, nEndCol,MaxRow(),nTab);
657 if (DrawGetPrintArea( aDrawRange, false, true ))
658 {
659 if (aDrawRange.aEnd.Row()>rEndRow) rEndRow=aDrawRange.aEnd.Row();
660 bAny = true;
661 }
662 }
663 return bAny;
664 }
665
666 rEndRow = 0;
667 return false;
668}
669
670bool ScDocument::GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const
671{
672 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
673 {
674 bool bAny = maTabs[nTab]->GetDataStart( rStartCol, rStartRow );
675 if (mpDrawLayer)
676 {
677 ScRange aDrawRange(0,0,nTab, MaxCol(),MaxRow(),nTab);
678 if (DrawGetPrintArea( aDrawRange, true, true ))
679 {
680 if (aDrawRange.aStart.Col()<rStartCol) rStartCol=aDrawRange.aStart.Col();
681 if (aDrawRange.aStart.Row()<rStartRow) rStartRow=aDrawRange.aStart.Row();
682 bAny = true;
683 }
684 }
685 return bAny;
686 }
687
688 rStartCol = 0;
689 rStartRow = 0;
690 return false;
691}
692
693void ScDocument::GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const
694{
695 bool bHasPrintArea = GetPrintArea(nTab, rEndCol, rEndRow, false);
696
697 // we need some reasonable minimal document size
698 ScViewData* pViewData = ScDocShell::GetViewData();
699 if (!pViewData)
700 {
701 if (!bHasPrintArea)
702 {
703 rEndCol = 20;
704 rEndRow = 50;
705 }
706 else
707 {
708 rEndCol += 20;
709 rEndRow += 50;
710 }
711 }
712 else if (!bHasPrintArea)
713 {
714 rEndCol = pViewData->GetMaxTiledCol();
715 rEndRow = pViewData->GetMaxTiledRow();
716 }
717 else
718 {
719 rEndCol = std::max(rEndCol, pViewData->GetMaxTiledCol());
720 rEndRow = std::max(rEndRow, pViewData->GetMaxTiledRow());
721 }
722}
723
724bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
725{
726 if (nOldPos == nNewPos)
727 return false;
728
729 SCTAB nTabCount = static_cast<SCTAB>(maTabs.size());
730 if(nTabCount < 2)
731 return false;
732
733 bool bValid = false;
734 if (ValidTab(nOldPos) && nOldPos < nTabCount )
735 {
736 if (maTabs[nOldPos])
737 {
738 sc::AutoCalcSwitch aACSwitch(*this, false);
739 sc::DelayDeletingBroadcasters delayDeletingBroadcasters(*this);
740
741 SetNoListening( true );
742 if (nNewPos == SC_TAB_APPEND || nNewPos >= nTabCount)
743 nNewPos = nTabCount-1;
744
745 // Update Reference
746 // TODO: combine with UpdateReference!
747
748 sc::RefUpdateMoveTabContext aCxt( *this, nOldPos, nNewPos);
749
750 SCTAB nDz = nNewPos - nOldPos;
751 ScRange aSourceRange( 0,0,nOldPos, MaxCol(),MaxRow(),nOldPos );
752 if (pRangeName)
753 pRangeName->UpdateMoveTab(aCxt);
754
755 pDBCollection->UpdateMoveTab( nOldPos, nNewPos );
756 xColNameRanges->UpdateReference( URM_REORDER, this, aSourceRange, 0,0,nDz );
757 xRowNameRanges->UpdateReference( URM_REORDER, this, aSourceRange, 0,0,nDz );
758 if (pDPCollection)
759 pDPCollection->UpdateReference( URM_REORDER, aSourceRange, 0,0,nDz );
760 if (pDetOpList)
761 pDetOpList->UpdateReference( this, URM_REORDER, aSourceRange, 0,0,nDz );
763 0,0,nOldPos, MaxCol(),MaxRow(),nOldPos, 0,0,nDz );
764 UpdateRefAreaLinks( URM_REORDER, aSourceRange, 0,0,nDz );
765 if ( pValidationList )
766 pValidationList->UpdateMoveTab(aCxt);
767 if ( pUnoBroadcaster )
769 aSourceRange, 0,0,nDz ) );
770
771 ScTableUniquePtr pSaveTab = std::move(maTabs[nOldPos]);
772 maTabs.erase(maTabs.begin()+nOldPos);
773 maTabs.insert(maTabs.begin()+nNewPos, std::move(pSaveTab));
774 for (SCTAB i = 0; i < nTabCount; i++)
775 if (maTabs[i])
776 maTabs[i]->UpdateMoveTab(aCxt, i, pProgress);
777 for (auto& rxTab : maTabs)
778 if (rxTab)
779 rxTab->UpdateCompile();
780 SetNoListening( false );
782
783 sc::SetFormulaDirtyContext aFormulaDirtyCxt;
784 SetAllFormulasDirty(aFormulaDirtyCxt);
785
786 if (mpDrawLayer)
787 mpDrawLayer->ScMovePage( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) );
788
789 bValid = true;
790 }
791 }
792 return bValid;
793}
794
795bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyMarked )
796{
797 if (SC_TAB_APPEND == nNewPos || nNewPos >= static_cast<SCTAB>(maTabs.size()))
798 nNewPos = static_cast<SCTAB>(maTabs.size());
799 OUString aName;
800 GetName(nOldPos, aName);
801
802 // check first if Prefix is valid; if not, then only avoid duplicates
803 bool bPrefix = ValidTabName( aName );
804 OSL_ENSURE(bPrefix, "invalid table name");
805 SCTAB nDummy;
806
808
809 bool bValid;
810 if (bPrefix)
811 bValid = ValidNewTabName(aName);
812 else
813 bValid = !GetTable( aName, nDummy );
814
815 sc::AutoCalcSwitch aACSwitch(*this, false);
816 sc::RefUpdateInsertTabContext aCxt( *this, nNewPos, 1);
817
818 if (bValid)
819 {
820 if (nNewPos >= static_cast<SCTAB>(maTabs.size()))
821 {
822 nNewPos = static_cast<SCTAB>(maTabs.size());
823 maTabs.emplace_back(new ScTable(*this, nNewPos, aName));
824 }
825 else
826 {
827 if (ValidTab(nNewPos) && (nNewPos < static_cast<SCTAB>(maTabs.size())))
828 {
829 SetNoListening( true );
830
831 ScRange aRange( 0,0,nNewPos, MaxCol(),MaxRow(),MAXTAB );
832 xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 );
833 xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 );
834 if (pRangeName)
835 pRangeName->UpdateInsertTab(aCxt);
836
837 pDBCollection->UpdateReference(
838 URM_INSDEL, 0,0,nNewPos, MaxCol(),MaxRow(),MAXTAB, 0,0,1 );
839 if (pDPCollection)
840 pDPCollection->UpdateReference( URM_INSDEL, aRange, 0,0,1 );
841 if (pDetOpList)
842 pDetOpList->UpdateReference( this, URM_INSDEL, aRange, 0,0,1 );
843 UpdateChartRef( URM_INSDEL, 0,0,nNewPos, MaxCol(),MaxRow(),MAXTAB, 0,0,1 );
844 UpdateRefAreaLinks( URM_INSDEL, aRange, 0,0,1 );
845 if ( pUnoBroadcaster )
846 pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,1 ) );
847
848 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
849 if (*it && it != (maTabs.begin() + nOldPos))
850 (*it)->UpdateInsertTab(aCxt);
851 if (nNewPos <= nOldPos)
852 nOldPos++;
853 maTabs.emplace(maTabs.begin() + nNewPos, new ScTable(*this, nNewPos, aName));
854 bValid = true;
855 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
856 if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin() + nNewPos)
857 (*it)->UpdateCompile();
858 SetNoListening( false );
859 sc::StartListeningContext aSLCxt(*this);
860 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
861 if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin()+nNewPos)
862 (*it)->StartListeners(aSLCxt, true);
863
864 if (pValidationList)
865 pValidationList->UpdateInsertTab(aCxt);
866 }
867 else
868 bValid = false;
869 }
870 }
871
872 if (bValid)
873 {
874 SetNoListening( true ); // not yet at CopyToTable/Insert
875
876 const bool bGlobalNamesToLocal = true;
877 const SCTAB nRealOldPos = (nNewPos < nOldPos) ? nOldPos - 1 : nOldPos;
878 const ScRangeName* pNames = GetRangeName( nOldPos);
879 if (pNames)
880 pNames->CopyUsedNames( nOldPos, nRealOldPos, nNewPos, *this, *this, bGlobalNamesToLocal);
881 GetRangeName()->CopyUsedNames( -1, nRealOldPos, nNewPos, *this, *this, bGlobalNamesToLocal);
882
883 sc::CopyToDocContext aCopyDocCxt(*this);
884 pDBCollection->CopyToTable(nOldPos, nNewPos);
885 maTabs[nOldPos]->CopyToTable(aCopyDocCxt, 0, 0, MaxCol(), MaxRow(), InsertDeleteFlags::ALL,
886 (pOnlyMarked != nullptr), maTabs[nNewPos].get(), pOnlyMarked,
887 false /*bAsLink*/, true /*bColRowFlags*/, bGlobalNamesToLocal, false /*bCopyCaptions*/ );
888 maTabs[nNewPos]->SetTabBgColor(maTabs[nOldPos]->GetTabBgColor());
889
890 SCTAB nDz = nNewPos - nOldPos;
891 sc::RefUpdateContext aRefCxt(*this);
892 aRefCxt.meMode = URM_COPY;
893 aRefCxt.maRange = ScRange(0, 0, nNewPos, MaxCol(), MaxRow(), nNewPos);
894 aRefCxt.mnTabDelta = nDz;
895 maTabs[nNewPos]->UpdateReference(aRefCxt);
896
897 maTabs[nNewPos]->UpdateInsertTabAbs(nNewPos); // move all paragraphs up by one!!
898 maTabs[nOldPos]->UpdateInsertTab(aCxt);
899
900 maTabs[nOldPos]->UpdateCompile();
901 maTabs[nNewPos]->UpdateCompile( true ); // maybe already compiled in Clone, but used names need recompilation
902 SetNoListening( false );
903 sc::StartListeningContext aSLCxt(*this);
904 maTabs[nOldPos]->StartListeners(aSLCxt, true);
905 maTabs[nNewPos]->StartListeners(aSLCxt, true);
906
907 sc::SetFormulaDirtyContext aFormulaDirtyCxt;
908 SetAllFormulasDirty(aFormulaDirtyCxt);
909
910 if (mpDrawLayer) // Skip cloning Note caption object
911 // page is already created in ScTable ctor
912 mpDrawLayer->ScCopyPage( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) );
913
914 if (pDPCollection)
915 pDPCollection->CopyToTab(nOldPos, nNewPos);
916
917 maTabs[nNewPos]->SetPageStyle( maTabs[nOldPos]->GetPageStyle() );
918 maTabs[nNewPos]->SetPendingRowHeights( maTabs[nOldPos]->IsPendingRowHeights() );
919
920 // Copy the custom print range if exists.
921 maTabs[nNewPos]->CopyPrintRange(*maTabs[nOldPos]);
922
923 // Copy the RTL settings
924 maTabs[nNewPos]->SetLayoutRTL(maTabs[nOldPos]->IsLayoutRTL());
925 maTabs[nNewPos]->SetLoadingRTL(maTabs[nOldPos]->IsLoadingRTL());
926
927 // Finally copy the note captions, which need
928 // 1. the updated source ScColumn::nTab members if nNewPos <= nOldPos
929 // 2. row heights and column widths of the destination
930 // 3. RTL settings of the destination
931 maTabs[nOldPos]->CopyCaptionsToTable( 0, 0, MaxCol(), MaxRow(), maTabs[nNewPos].get(), true /*bCloneCaption*/);
932 }
933
934 return bValid;
935}
936
938 SCTAB nDestPos, bool bInsertNew,
939 bool bResultsOnly )
940{
941 sal_uLong nRetVal = 1; // 0 => error 1 = ok
942 // 3 => NameBox
943 // 4 => both
944
945 if (rSrcDoc.mpShell->GetMedium())
946 {
948 // for unsaved files use the title name and adjust during save of file
949 if (rSrcDoc.maFileURL.isEmpty())
950 rSrcDoc.maFileURL = rSrcDoc.mpShell->GetName();
951 }
952 else
953 {
954 rSrcDoc.maFileURL = rSrcDoc.mpShell->GetName();
955 }
956
957 bool bValid = true;
958 if (bInsertNew) // re-insert
959 {
960 OUString aName;
961 rSrcDoc.GetName(nSrcPos, aName);
963 bValid = InsertTab(nDestPos, aName);
964
965 // Copy the RTL settings
966 maTabs[nDestPos]->SetLayoutRTL(rSrcDoc.maTabs[nSrcPos]->IsLayoutRTL());
967 maTabs[nDestPos]->SetLoadingRTL(rSrcDoc.maTabs[nSrcPos]->IsLoadingRTL());
968 }
969 else // replace existing tables
970 {
971 if (ValidTab(nDestPos) && nDestPos < static_cast<SCTAB>(maTabs.size()) && maTabs[nDestPos])
972 {
973 maTabs[nDestPos]->DeleteArea( 0,0, MaxCol(),MaxRow(), InsertDeleteFlags::ALL );
974 }
975 else
976 bValid = false;
977 }
978
979 if (bValid)
980 {
981 bool bOldAutoCalcSrc = false;
982 bool bOldAutoCalc = GetAutoCalc();
983 SetAutoCalc( false ); // avoid repeated calculations
984 SetNoListening( true );
985 if ( bResultsOnly )
986 {
987 bOldAutoCalcSrc = rSrcDoc.GetAutoCalc();
988 rSrcDoc.SetAutoCalc( true ); // in case something needs calculation
989 }
990
991 {
992 NumFmtMergeHandler aNumFmtMergeHdl(*this, rSrcDoc);
993
994 sc::CopyToDocContext aCxt(*this);
995 nDestPos = std::min(nDestPos, static_cast<SCTAB>(GetTableCount() - 1));
996 { // scope for bulk broadcast
997 ScBulkBroadcast aBulkBroadcast( pBASM.get(), SfxHintId::ScDataChanged);
998 if (!bResultsOnly)
999 {
1000 const bool bGlobalNamesToLocal = false;
1001 const ScRangeName* pNames = rSrcDoc.GetRangeName( nSrcPos);
1002 if (pNames)
1003 pNames->CopyUsedNames( nSrcPos, nSrcPos, nDestPos, rSrcDoc, *this, bGlobalNamesToLocal);
1004 rSrcDoc.GetRangeName()->CopyUsedNames( -1, nSrcPos, nDestPos, rSrcDoc, *this, bGlobalNamesToLocal);
1005 }
1006 rSrcDoc.maTabs[nSrcPos]->CopyToTable(aCxt, 0, 0, MaxCol(), MaxRow(),
1008 false, maTabs[nDestPos].get(), /*pMarkData*/nullptr, /*bAsLink*/false, /*bColRowFlags*/true,
1009 /*bGlobalNamesToLocal*/false, /*bCopyCaptions*/true );
1010 }
1011 }
1012 maTabs[nDestPos]->SetTabNo(nDestPos);
1013 maTabs[nDestPos]->SetTabBgColor(rSrcDoc.maTabs[nSrcPos]->GetTabBgColor());
1014
1015 if ( !bResultsOnly )
1016 {
1017 sc::RefUpdateContext aRefCxt(*this);
1018 aRefCxt.meMode = URM_COPY;
1019 aRefCxt.maRange = ScRange(0, 0, nDestPos, MaxCol(), MaxRow(), nDestPos);
1020 aRefCxt.mnTabDelta = nDestPos - nSrcPos;
1021 maTabs[nDestPos]->UpdateReference(aRefCxt);
1022
1023 // Readjust self-contained absolute references to this sheet
1024 maTabs[nDestPos]->TestTabRefAbs(nSrcPos);
1025 sc::CompileFormulaContext aFormulaCxt(*this);
1026 maTabs[nDestPos]->CompileAll(aFormulaCxt);
1027 }
1028
1029 SetNoListening( false );
1030 if ( !bResultsOnly )
1031 {
1032 sc::StartListeningContext aSLCxt(*this);
1033 maTabs[nDestPos]->StartListeners(aSLCxt, true);
1034 }
1035 SetDirty( ScRange( 0, 0, nDestPos, MaxCol(), MaxRow(), nDestPos), false);
1036
1037 if ( bResultsOnly )
1038 rSrcDoc.SetAutoCalc( bOldAutoCalcSrc );
1039 SetAutoCalc( bOldAutoCalc );
1040
1041 // copy Drawing
1042
1043 if (bInsertNew)
1044 TransferDrawPage( rSrcDoc, nSrcPos, nDestPos );
1045
1046 maTabs[nDestPos]->SetPendingRowHeights( rSrcDoc.maTabs[nSrcPos]->IsPendingRowHeights() );
1047 }
1048 if (!bValid)
1049 nRetVal = 0;
1050 bool bVbaEnabled = IsInVBAMode();
1051
1052 if ( bVbaEnabled )
1053 {
1054 SfxObjectShell* pSrcShell = rSrcDoc.GetDocumentShell();
1055 if ( pSrcShell )
1056 {
1057 OUString aLibName("Standard");
1058#if HAVE_FEATURE_SCRIPTING
1059 const BasicManager *pBasicManager = pSrcShell->GetBasicManager();
1060 if (pBasicManager && !pBasicManager->GetName().isEmpty())
1061 {
1062 aLibName = pSrcShell->GetBasicManager()->GetName();
1063 }
1064#endif
1065 OUString sSource;
1066 uno::Reference< script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer();
1067 uno::Reference< container::XNameContainer > xLib;
1068 if( xLibContainer.is() )
1069 {
1070 uno::Any aLibAny = xLibContainer->getByName(aLibName);
1071 aLibAny >>= xLib;
1072 }
1073
1074 if( xLib.is() )
1075 {
1076 OUString sSrcCodeName;
1077 rSrcDoc.GetCodeName( nSrcPos, sSrcCodeName );
1078 OUString sRTLSource;
1079 xLib->getByName( sSrcCodeName ) >>= sRTLSource;
1080 sSource = sRTLSource;
1081 }
1082 VBA_InsertModule( *this, nDestPos, sSource );
1083 }
1084 }
1085
1086 return nRetVal;
1087}
1088
1089void ScDocument::SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError)
1090{
1091 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
1092 if (maTabs[nTab])
1093 maTabs[nTab]->SetError( nCol, nRow, nError );
1094}
1095
1097 const ScAddress& rPos, const ScTokenArray& rArray )
1098{
1099 if (!TableExists(rPos.Tab()))
1100 return;
1101
1102 maTabs[rPos.Tab()]->SetFormula(rPos.Col(), rPos.Row(), rArray, formula::FormulaGrammar::GRAM_DEFAULT);
1103}
1104
1106 const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram )
1107{
1108 if (!TableExists(rPos.Tab()))
1109 return;
1110
1111 maTabs[rPos.Tab()]->SetFormula(rPos.Col(), rPos.Row(), rFormula, eGram);
1112}
1113
1115{
1116 if (!TableExists(rPos.Tab()))
1117 {
1118 delete pCell;
1119 return nullptr;
1120 }
1121
1122 return maTabs[rPos.Tab()]->SetFormulaCell(rPos.Col(), rPos.Row(), pCell);
1123}
1124
1125bool ScDocument::SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells )
1126{
1127 if (rCells.empty())
1128 return false;
1129
1130 ScTable* pTab = FetchTable(rPos.Tab());
1131 if (!pTab)
1132 return false;
1133
1134 return pTab->SetFormulaCells(rPos.Col(), rPos.Row(), rCells);
1135}
1136
1137void ScDocument::SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData )
1138{
1139 pConsolidateDlgData = std::move(pData);
1140}
1141
1143{
1144 if (pChangeViewSettings==nullptr)
1146
1147 *pChangeViewSettings=rNew;
1148}
1149
1150std::unique_ptr<ScFieldEditEngine> ScDocument::CreateFieldEditEngine()
1151{
1152 std::unique_ptr<ScFieldEditEngine> pNewEditEngine;
1154 {
1155 pNewEditEngine.reset( new ScFieldEditEngine(
1156 this, GetEnginePool(), GetEditPool(), false) );
1157 }
1158 else
1159 {
1160 if ( !bImportingXML )
1161 {
1162 // #i66209# previous use might not have restored update mode,
1163 // ensure same state as for a new EditEngine (UpdateMode = true)
1164 pCacheFieldEditEngine->SetUpdateLayout(true);
1165 }
1166
1167 pNewEditEngine = std::move(pCacheFieldEditEngine);
1168 }
1169 return pNewEditEngine;
1170}
1171
1172void ScDocument::DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine)
1173{
1174 if (!pCacheFieldEditEngine && rpEditEngine)
1175 {
1176 pCacheFieldEditEngine = std::move( rpEditEngine );
1177 pCacheFieldEditEngine->Clear();
1178 }
1179 else
1180 rpEditEngine.reset();
1181}
1182
1184{
1185 ScLookupCache* pCache = nullptr;
1186 if (!pContext->mxScLookupCache)
1187 pContext->mxScLookupCache.reset(new ScLookupCacheMap);
1188 ScLookupCacheMap* pCacheMap = pContext->mxScLookupCache.get();
1189 // insert with temporary value to avoid doing two lookups
1190 auto [findIt, bInserted] = pCacheMap->aCacheMap.emplace(rRange, nullptr);
1191 if (bInserted)
1192 {
1193 findIt->second = std::make_unique<ScLookupCache>(this, rRange, *pCacheMap);
1194 pCache = findIt->second.get();
1195 // The StartListeningArea() call is not thread-safe, as all threads
1196 // would access the same SvtBroadcaster.
1197 std::unique_lock guard( mScLookupMutex );
1198 StartListeningArea(rRange, false, pCache);
1199 }
1200 else
1201 pCache = (*findIt).second.get();
1202
1203 return *pCache;
1204}
1205
1207 ScInterpreterContext* pContext )
1208{
1209 assert(mxScSortedRangeCache);
1211 // This should be created just once for one range, and repeated calls should reuse it, even
1212 // between threads (it doesn't make sense to use ScInterpreterContext and have all threads
1213 // build their own copy of the same data). So first try read-only access, which should
1214 // in most cases be enough.
1215 {
1216 std::shared_lock guard(mScLookupMutex);
1217 auto findIt = mxScSortedRangeCache->aCacheMap.find(key);
1218 if( findIt != mxScSortedRangeCache->aCacheMap.end())
1219 return *findIt->second;
1220 }
1221 // Avoid recursive calls because of some cells in the range being dirty and triggering
1222 // interpreting, which may call into this again. Threaded calculation makes sure
1223 // no cells are dirty. If some cells in the range cannot be interpreted and remain
1224 // dirty e.g. because of circular dependencies, create only an invalid empty cache to prevent
1225 // a possible recursive deadlock.
1226 bool invalid = false;
1228 if(!InterpretCellsIfNeeded(rRange))
1229 invalid = true;
1230 std::unique_lock guard(mScLookupMutex);
1231 auto [findIt, bInserted] = mxScSortedRangeCache->aCacheMap.emplace(key, nullptr);
1232 if (bInserted)
1233 {
1234 findIt->second = std::make_unique<ScSortedRangeCache>(this, rRange, param, pContext, invalid);
1235 StartListeningArea(rRange, false, findIt->second.get());
1236 }
1237 return *findIt->second;
1238}
1239
1241{
1242 // Data changes leading to this should never happen during calculation (they are either
1243 // a result of user input or recalc). If it turns out this can be the case, locking is needed
1244 // here and also in ScLookupCache::Notify().
1246 auto & cacheMap = rCache.getCacheMap();
1247 auto it(cacheMap.aCacheMap.find(rCache.getRange()));
1248 if (it != cacheMap.aCacheMap.end())
1249 {
1250 std::unique_ptr<ScLookupCache> xCache = std::move(it->second);
1251 cacheMap.aCacheMap.erase(it);
1252 assert(!IsThreadedGroupCalcInProgress()); // EndListeningArea() is not thread-safe
1253 EndListeningArea(xCache->getRange(), false, &rCache);
1254 return;
1255 }
1256 OSL_FAIL( "ScDocument::RemoveLookupCache: range not found in hash map");
1257}
1258
1260{
1261 // Data changes leading to this should never happen during calculation (they are either
1262 // a result of user input or recalc). If it turns out this can be the case, locking is needed
1263 // here and also in ScSortedRangeCache::Notify().
1265 auto it(mxScSortedRangeCache->aCacheMap.find(rCache.getHashKey()));
1266 if (it != mxScSortedRangeCache->aCacheMap.end())
1267 {
1268 std::unique_ptr<ScSortedRangeCache> xCache = std::move(it->second);
1269 mxScSortedRangeCache->aCacheMap.erase(it);
1270 assert(!IsThreadedGroupCalcInProgress()); // EndListeningArea() is not thread-safe
1271 EndListeningArea(xCache->getRange(), false, &rCache);
1272 return;
1273 }
1274 OSL_FAIL( "ScDocument::RemoveSortedRangeCache: range not found in hash map");
1275}
1276
1278{
1281 mxScSortedRangeCache->aCacheMap.clear();
1282 // Clear lookup cache in all interpreter-contexts in the (threaded/non-threaded) pools.
1284}
1285
1286bool ScDocument::IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder)
1287{
1288 ScChangeTrack* pTrack = GetChangeTrack();
1290 if ( !pTrack || !pTrack->GetFirst() || !pSettings || !pSettings->ShowChanges() )
1291 return false; // missing or turned-off
1292 ScActionColorChanger aColorChanger(*pTrack);
1293 // Clipping happens from outside
1295 const ScChangeAction* pAction = pTrack->GetFirst();
1296 while (pAction)
1297 {
1298 if ( pAction->IsVisible() )
1299 {
1300 ScChangeActionType eType = pAction->GetType();
1301 const ScBigRange& rBig = pAction->GetBigRange();
1302 if ( rBig.aStart.Tab() == cell.Tab())
1303 {
1304 ScRange aRange = rBig.MakeRange( *this );
1305 if ( eType == SC_CAT_DELETE_ROWS )
1306 aRange.aEnd.SetRow( aRange.aStart.Row() );
1307 else if ( eType == SC_CAT_DELETE_COLS )
1308 aRange.aEnd.SetCol( aRange.aStart.Col() );
1309 if (ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
1310 {
1311 if (aRange.Contains(cell))
1312 {
1313 if (pColCellBorder != nullptr)
1314 {
1315 aColorChanger.Update( *pAction );
1316 Color aColor( aColorChanger.GetColor() );
1317 *pColCellBorder = aColor;
1318 }
1319 return true;
1320 }
1321 }
1322 }
1323 if ( eType == SC_CAT_MOVE &&
1324 static_cast<const ScChangeActionMove*>(pAction)->
1325 GetFromRange().aStart.Tab() == cell.Col() )
1326 {
1327 ScRange aRange = static_cast<const ScChangeActionMove*>(pAction)->
1328 GetFromRange().MakeRange( *this );
1329 if (ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
1330 {
1331 if (aRange.Contains(cell))
1332 {
1333 if (pColCellBorder != nullptr)
1334 {
1335 aColorChanger.Update( *pAction );
1336 Color aColor( aColorChanger.GetColor() );
1337 *pColCellBorder = aColor;
1338 }
1339 return true;
1340 }
1341 }
1342 }
1343 }
1344 pAction = pAction->GetNext();
1345 }
1346 return false;
1347}
1348
1349void ScDocument::GetCellChangeTrackNote( const ScAddress &aCellPos, OUString &aTrackText,bool &bLeftEdge)
1350{
1351 aTrackText.clear();
1352 // Change-Tracking
1353 ScChangeTrack* pTrack = GetChangeTrack();
1355 if ( !(pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges()))
1356 return;
1357
1358 const ScChangeAction* pFound = nullptr;
1359 const ScChangeAction* pFoundContent = nullptr;
1360 const ScChangeAction* pFoundMove = nullptr;
1361 const ScChangeAction* pAction = pTrack->GetFirst();
1362 while (pAction)
1363 {
1364 if ( pAction->IsVisible() &&
1365 ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
1366 {
1367 ScChangeActionType eType = pAction->GetType();
1368 const ScBigRange& rBig = pAction->GetBigRange();
1369 if ( rBig.aStart.Tab() == aCellPos.Tab())
1370 {
1371 ScRange aRange = rBig.MakeRange( *this );
1372 if ( eType == SC_CAT_DELETE_ROWS )
1373 aRange.aEnd.SetRow( aRange.aStart.Row() );
1374 else if ( eType == SC_CAT_DELETE_COLS )
1375 aRange.aEnd.SetCol( aRange.aStart.Col() );
1376 if ( aRange.Contains( aCellPos ) )
1377 {
1378 pFound = pAction; // the last wins
1379 switch ( eType )
1380 {
1381 case SC_CAT_CONTENT :
1382 pFoundContent = pAction;
1383 break;
1384 case SC_CAT_MOVE :
1385 pFoundMove = pAction;
1386 break;
1387 default:
1388 break;
1389 }
1390 }
1391 }
1392 if ( eType == SC_CAT_MOVE )
1393 {
1394 ScRange aRange =
1395 static_cast<const ScChangeActionMove*>(pAction)->
1396 GetFromRange().MakeRange( *this );
1397 if ( aRange.Contains( aCellPos ) )
1398 {
1399 pFound = pAction;
1400 }
1401 }
1402 }
1403 pAction = pAction->GetNext();
1404 }
1405 if ( !pFound )
1406 return;
1407
1408 if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT )
1409 pFound = pFoundContent; // Content wins
1410 if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE &&
1411 pFoundMove->GetActionNumber() >
1412 pFound->GetActionNumber() )
1413 pFound = pFoundMove; // Move wins
1414 // for deleted columns: arrow on left side of row
1415 if ( pFound->GetType() == SC_CAT_DELETE_COLS )
1416 bLeftEdge = true;
1417 DateTime aDT = pFound->GetDateTime();
1418 aTrackText = pFound->GetUser();
1419 aTrackText += ", ";
1420 aTrackText += ScGlobal::getLocaleData().getDate(aDT);
1421 aTrackText += " ";
1422 aTrackText += ScGlobal::getLocaleData().getTime(aDT);
1423 aTrackText += ":\n";
1424 OUString aComStr = pFound->GetComment();
1425 if(!aComStr.isEmpty())
1426 {
1427 aTrackText += aComStr;
1428 aTrackText += "\n( ";
1429 }
1430 aTrackText = pFound->GetDescription( *this );
1431 if (!aComStr.isEmpty())
1432 {
1433 aTrackText += ")";
1434 }
1435}
1436
1437void ScDocument::SetPreviewFont( std::unique_ptr<SfxItemSet> pFont )
1438{
1439 pPreviewFont = std::move(pFont);
1440}
1441
1443{
1444 maPreviewSelection = rSel;
1445}
1446
1448{
1449 SfxItemSet* pRet = nullptr;
1450 if ( pPreviewFont )
1451 {
1453 if ( aSel.IsCellMarked( nCol, nRow ) && aSel.GetFirstSelected() == nTab )
1454 pRet = pPreviewFont.get();
1455 }
1456 return pRet;
1457}
1458
1460{
1461 ScStyleSheet* pRet = nullptr;
1463 if ( pPreviewCellStyle && aSel.IsCellMarked( nCol, nRow ) && aSel.GetFirstSelected() == nTab )
1464 pRet = pPreviewCellStyle;
1465 return pRet;
1466}
1467
1469{
1471 {
1473 }
1474 return *m_pIconSetBitmapMap;
1475}
1476
1477/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
const SCROW MAXROW_JUMBO
Definition: address.hxx:74
const SCROW MAXROW
Definition: address.hxx:68
const SCTAB MAXTAB
Definition: address.hxx:70
const SCTAB SC_TAB_APPEND
Definition: address.hxx:90
const SCCOL MAXCOL_JUMBO
Definition: address.hxx:75
const SCCOL MAXCOL
Definition: address.hxx:69
CharCompressType
ScChangeActionType
Definition: chgtrack.hxx:63
@ SC_CAT_MOVE
Definition: chgtrack.hxx:71
@ SC_CAT_DELETE_ROWS
Definition: chgtrack.hxx:69
@ SC_CAT_CONTENT
Definition: chgtrack.hxx:72
@ SC_CAT_DELETE_COLS
Definition: chgtrack.hxx:68
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
virtual void Start(bool bStartTimer=true) override
OUString getDate(const Date &rDate) const
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
Color GetColor() const
Definition: chgtrack.hxx:59
void Update(const ScChangeAction &rAction)
Definition: output.cxx:94
static void RemoveDocument(ScDocument *pDocument)
Definition: adiasync.cxx:118
static void RemoveDocument(ScDocument *pDocument)
Definition: addinlis.cxx:78
SCTAB Tab() const
Definition: address.hxx:283
void SetCol(SCCOL nColP)
Definition: address.hxx:291
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
SCCOL Col() const
Definition: address.hxx:279
sal_Int64 Tab() const
Definition: bigrange.hxx:46
ScBigAddress aStart
Definition: bigrange.hxx:108
ScRange MakeRange(const ScDocument &rDoc) const
Definition: bigrange.hxx:134
BroadcastAreaSlots and their management, once per document.
Definition: bcaslot.hxx:246
const OUString & GetComment() const
Definition: chgtrack.hxx:350
ScBigRange & GetBigRange()
Definition: chgtrack.hxx:231
bool IsVisible() const
Definition: chgtrack.cxx:142
sal_uLong GetActionNumber() const
Definition: chgtrack.hxx:319
ScChangeActionType GetType() const
Definition: chgtrack.hxx:317
virtual OUString GetDescription(ScDocument &rDoc, bool bSplitRange=false, bool bWarning=true) const
Definition: chgtrack.cxx:420
ScChangeAction * GetNext() const
Definition: chgtrack.hxx:322
SC_DLLPUBLIC DateTime GetDateTime() const
Definition: chgtrack.cxx:406
const OUString & GetUser() const
Definition: chgtrack.hxx:349
ScChangeAction * GetFirst() const
Definition: chgtrack.hxx:953
bool ShowChanges() const
Definition: chgviset.hxx:77
static ScViewData * GetViewData()
Definition: docsh4.cxx:2592
Use this class as a locale variable to merge number formatter from another document,...
Definition: document.hxx:2657
SC_DLLPUBLIC bool InsertTab(SCTAB nPos, const OUString &rName, bool bExternalDocument=false, bool bUndoDeleteTab=false)
Definition: document.cxx:507
void StartAllListeners()
Definition: documen7.cxx:588
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
Definition: documen2.cxx:478
std::shared_ptr< svl::SharedStringPool > mpCellStringPool
Definition: document.hxx:359
rtl::Reference< ScSheetLimits > mxSheetLimits
Definition: document.hxx:378
SC_DLLPUBLIC ~ScDocument()
Definition: documen2.cxx:346
friend class ScTable
Definition: document.hxx:338
std::unique_ptr< ScFieldEditEngine > pCacheFieldEditEngine
Definition: document.hxx:404
OUString maFileURL
Definition: document.hxx:418
bool IsCellInChangeTrack(const ScAddress &cell, Color *pColCellBorder)
Definition: documen2.cxx:1286
std::unique_ptr< SvMemoryStream > pClipData
Definition: document.hxx:391
bool bInLinkUpdate
Definition: document.hxx:509
std::unique_ptr< ScConsolidateParam > pConsolidateDlgData
Definition: document.hxx:426
SC_DLLPUBLIC void SetChangeTrack(std::unique_ptr< ScChangeTrack > pTrack)
only for import filter, deletes any existing ChangeTrack via EndChangeTracking() and takes ownership ...
Definition: documen2.cxx:294
SC_DLLPUBLIC ScFormulaCell * SetFormulaCell(const ScAddress &rPos, ScFormulaCell *pCell)
Set formula cell, and transfer its ownership to the document.
Definition: documen2.cxx:1114
void ClosingClipboardSource()
To be called at the clipboard document when closing a document that is the current clipboard source t...
Definition: documen2.cxx:338
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
Definition: document.cxx:6165
std::unique_ptr< ScFieldEditEngine > mpEditEngine
Definition: document.hxx:368
void UpdateRefAreaLinks(UpdateRefMode eUpdateRefMode, const ScRange &r, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: documen8.cxx:1083
void Clear(bool bFromDestructor=false)
Definition: documen9.cxx:501
bool bInDtorClear
Definition: document.hxx:514
SC_DLLPUBLIC ScRangeName * GetRangeName() const
Definition: documen3.cxx:182
SC_DLLPUBLIC sal_uLong TransferTab(ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew=true, bool bResultsOnly=false)
Definition: documen2.cxx:937
ScTable * FetchTable(SCTAB nTab)
Definition: document.cxx:2545
std::unique_ptr< ScUnoListenerCalls > pUnoListenerCalls
Definition: document.hxx:395
SC_DLLPUBLIC void SetFormula(const ScAddress &rPos, const ScTokenArray &rArray)
Definition: documen2.cxx:1096
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
ScAddress aCurTextWidthCalcPos
Definition: document.hxx:438
VclPtr< SfxPrinter > mpPrinter
Definition: document.hxx:371
std::unique_ptr< ScDBData > mpAnonymousDBData
Definition: document.hxx:401
SC_DLLPUBLIC bool ValidNewTabName(const OUString &rName) const
Definition: document.cxx:377
void EndListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
Definition: documen7.cxx:61
ScStyleSheet * pPreviewCellStyle
Definition: document.hxx:431
bool SetFormulaCells(const ScAddress &rPos, std::vector< ScFormulaCell * > &rCells)
Definition: documen2.cxx:1125
ScDocumentThreadSpecific maNonThreaded
Definition: document.hxx:466
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:891
std::unique_ptr< SfxItemSet > pPreviewFont
Definition: document.hxx:430
std::unique_ptr< ScDPCollection > pDPCollection
Definition: document.hxx:382
SC_DLLPUBLIC bool GetPrintAreaVer(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW &rEndRow, bool bNotes) const
Definition: documen2.cxx:648
void SharePooledResources(const ScDocument *pSrcDoc)
Definition: document10.cxx:328
std::unique_ptr< ScSortedRangeCacheMap > mxScSortedRangeCache
Definition: document.hxx:475
std::unique_ptr< ScFormulaParserPool > mxFormulaParserPool
Definition: document.hxx:414
static const sal_uInt16 nSrcVer
Definition: document.hxx:477
rtl::Reference< ScPoolHelper > mxPoolHelper
Definition: document.hxx:357
static SC_DLLPUBLIC bool ValidTabName(const OUString &rName)
Definition: document.cxx:338
SC_DLLPUBLIC void EnsureTable(SCTAB nTab)
Definition: documen2.cxx:566
void SetExpandRefs(bool bVal)
Definition: documen2.cxx:327
std::unique_ptr< ScBroadcastAreaSlotMachine > pBASM
Definition: document.hxx:389
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:892
std::unique_ptr< ScChangeViewSettings > pChangeViewSettings
Definition: document.hxx:397
SC_DLLPUBLIC ScDocument(ScDocumentMode eMode=SCDOCMODE_DOCUMENT, SfxObjectShell *pDocShell=nullptr)
Definition: documen2.cxx:114
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:483
ScSortedRangeCache & GetSortedRangeCache(const ScRange &rRange, const ScQueryParam &param, ScInterpreterContext *pContext)
Definition: documen2.cxx:1206
std::unique_ptr< ScRefreshTimerControl > const & GetRefreshTimerControlAddress() const
Definition: document.hxx:2513
std::unique_ptr< ScAutoNameCache > pAutoNameCache
Definition: document.hxx:428
std::unique_ptr< ScPatternAttr > pSelectionAttr
Definition: document.hxx:384
ScLookupCache & GetLookupCache(const ScRange &rRange, ScInterpreterContext *pContext)
Creates a ScLookupCache cache for the range if it doesn't already exist.
Definition: documen2.cxx:1183
std::unique_ptr< SfxBroadcaster > pUnoBroadcaster
Definition: document.hxx:394
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: documen3.cxx:1958
void SetStorageGrammar(formula::FormulaGrammar::Grammar eGrammar)
Should only be GRAM_PODF or GRAM_ODFF.
Definition: documen2.cxx:251
ScInterpreterContext & GetNonThreadedContext() const
Definition: document.hxx:616
std::unique_ptr< ScValidationDataList > pValidationList
Definition: document.hxx:375
void SetConsolidateDlgData(std::unique_ptr< ScConsolidateParam > pData)
Definition: documen2.cxx:1137
void RemoveLookupCache(ScLookupCache &rCache)
Only ScLookupCache dtor uses RemoveLookupCache(), do not use elsewhere!
Definition: documen2.cxx:1240
ScRangePairListRef xRowNameRanges
Definition: document.hxx:420
bool bImportingXML
Definition: document.hxx:504
SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow) const
Return the number of columns / rows that should be visible for the tiled rendering.
Definition: documen2.cxx:693
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
Definition: documen2.cxx:1142
std::unique_ptr< sc::DocumentLinkManager > mpDocLinkMgr
Definition: document.hxx:360
SC_DLLPUBLIC const ScViewOptions & GetViewOptions() const
Definition: documen3.cxx:1967
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:473
std::unique_ptr< ScDetOpList > pDetOpList
Definition: document.hxx:392
std::unique_ptr< ScFieldEditEngine > CreateFieldEditEngine()
Definition: documen2.cxx:1150
SC_DLLPUBLIC bool GetAutoCalc() const
Definition: document.hxx:1411
bool IsInVBAMode() const
Definition: document.cxx:6607
void SetLanguage(LanguageType eLatin, LanguageType eCjk, LanguageType eCtl)
Definition: documen3.cxx:1986
ScChangeViewSettings * GetChangeViewSettings() const
Definition: document.hxx:2238
void StartTrackTimer()
Definition: documen2.cxx:332
void StartChangeTracking()
Definition: documen2.cxx:277
bool bExpandRefs
Definition: document.hxx:519
TableContainer maTabs
Definition: document.hxx:377
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
Definition: document.cxx:6302
bool bIsClip
Definition: document.hxx:493
void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge)
Definition: documen2.cxx:1349
std::unique_ptr< ScExternalRefManager > pExternalRefMgr
Definition: document.hxx:409
void SetAllFormulasDirty(const sc::SetFormulaDirtyContext &rCxt)
Definition: document.cxx:3877
formula::FormulaGrammar::Grammar eStorageGrammar
The compiler grammar used in document storage.
Definition: document.hxx:458
SC_DLLPUBLIC bool GetPrintAreaHor(SCTAB nTab, SCROW nStartRow, SCROW nEndRow, SCCOL &rEndCol) const
Definition: documen2.cxx:626
sal_uInt32 GetDocumentID() const
an ID unique to each document instance
Definition: documen2.cxx:268
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1973
bool IsPendingRowHeights(SCTAB nTab) const
Definition: document.cxx:948
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
Definition: document.cxx:395
std::unique_ptr< ScChangeTrack > pChangeTrack
Definition: document.hxx:393
void DisposeFieldEditEngine(std::unique_ptr< ScFieldEditEngine > &rpEditEngine)
Definition: documen2.cxx:1172
std::unique_ptr< sc::IconSetBitmapMap > m_pIconSetBitmapMap
Definition: document.hxx:567
void DeleteDrawLayer()
Definition: documen9.cxx:229
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
Definition: documen7.cxx:35
static thread_local ScDocumentThreadSpecific maThreadSpecific
Definition: document.hxx:470
friend struct ScRefCellValue
Definition: document.hxx:340
std::unique_ptr< ScUnoRefList > pUnoRefUndoList
Definition: document.hxx:396
std::shared_mutex mScLookupMutex
Definition: document.hxx:474
bool IsClipOrUndo() const
Definition: document.hxx:1590
void SetPreviewSelection(const ScMarkData &rSel)
Definition: documen2.cxx:1442
void SetError(SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError)
Definition: documen2.cxx:1089
SC_DLLPUBLIC void SetDocVisible(bool bSet)
Definition: documen2.cxx:261
bool bIsUndo
Definition: document.hxx:494
const OUString & GetCodeName() const
Definition: document.hxx:608
ScMarkData maPreviewSelection
Definition: document.hxx:432
void RemoveSortedRangeCache(ScSortedRangeCache &rCache)
Definition: documen2.cxx:1259
SC_DLLPUBLIC void TransferDrawPage(const ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos)
Definition: documen9.cxx:66
SC_DLLPUBLIC bool CopyTab(SCTAB nOldPos, SCTAB nNewPos, const ScMarkData *pOnlyMarked=nullptr)
Definition: documen2.cxx:795
void ImplDeleteOptions()
Definition: documen8.cxx:107
void SaveDdeLinks(SvStream &rStream) const
Definition: documen8.cxx:709
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1081
bool InterpretCellsIfNeeded(const ScRangeList &rRanges)
Definition: document.cxx:3955
SC_DLLPUBLIC ScNoteEditEngine & GetNoteEngine()
Definition: documen2.cxx:496
rtl_TextEncoding eSrcSet
Definition: document.hxx:454
bool TableExists(SCTAB nTab) const
Definition: document.cxx:2540
SC_DLLPUBLIC void ResetClip(ScDocument *pSourceDoc, const ScMarkData *pMarks)
Definition: documen2.cxx:514
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:592
std::unordered_map< ScColumn *, std::pair< SCROW, SCROW > > pDelayedStartListeningFormulaCells
Definition: document.hxx:528
VclPtr< VirtualDevice > mpVirtualDevice_100th_mm
Definition: document.hxx:372
void ApplyAsianEditSettings(ScEditEngineDefaulter &rEngine)
Definition: documen9.cxx:674
SfxItemSet * GetPreviewFont()
Definition: document.hxx:1388
std::unique_ptr< ScNoteEditEngine > mpNoteEngine
Definition: document.hxx:369
bool IsThreadedGroupCalcInProgress() const
Definition: document.hxx:629
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
std::unique_ptr< ScDBCollection > pDBCollection
Definition: document.hxx:381
std::unique_ptr< ScRefreshTimerControl > pRefreshTimerControl
Definition: document.hxx:399
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:174
SC_DLLPUBLIC void SetAutoCalc(bool bNewAutoCalc)
Definition: documen7.cxx:608
SC_DLLPUBLIC bool DrawGetPrintArea(ScRange &rRange, bool bSetHor, bool bSetVer) const
Definition: documen9.cxx:247
void SetPreviewFont(std::unique_ptr< SfxItemSet > pFontSet)
Definition: documen2.cxx:1437
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:241
std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock
Definition: document.hxx:383
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
Definition: documen2.cxx:602
void UpdateChartRef(UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: documen5.cxx:394
const ScMarkData & GetPreviewSelection() const
Definition: document.hxx:1390
sc::IconSetBitmapMap & GetIconSetBitmapMap()
Definition: documen2.cxx:1468
ScStyleSheet * GetPreviewCellStyle()
Definition: document.hxx:1392
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2487
void ImplCreateOptions()
Definition: documen8.cxx:101
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:998
std::unique_ptr< ScScriptTypeData > pScriptTypeData
Definition: document.hxx:398
void ForgetNoteCaptions(const ScRangeList &rRanges, bool bPreserveData)
Definition: document.cxx:6879
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:231
std::unique_ptr< ScDrawLayer > mpDrawLayer
Definition: document.hxx:373
SC_DLLPUBLIC bool GetDataStart(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow) const
Definition: documen2.cxx:670
SfxObjectShell * mpShell
Definition: document.hxx:370
void SetDirty(const ScRange &, bool bIncludeEmptyCells)
Definition: document.cxx:3899
void ClearLookupCaches()
Zap all caches.
Definition: documen2.cxx:1277
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:217
void SetNoListening(bool bVal)
Definition: document.hxx:2224
Idle aTrackIdle
Definition: document.hxx:440
ScRangePairListRef xColNameRanges
Definition: document.hxx:419
std::unique_ptr< ScRange > pDelayedFormulaGrouping
Definition: document.hxx:524
std::shared_ptr< sc::FormulaGroupContext > mpFormulaGroupCxt
Definition: document.hxx:362
bool MoveTab(SCTAB nOldPos, SCTAB nNewPos, ScProgress *pProgress=nullptr)
Definition: documen2.cxx:724
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1952
std::unique_ptr< ScRangeName > pRangeName
Definition: document.hxx:380
ScRefCellValue GetRefCellValue(const ScAddress &rPos)
Definition: documen2.cxx:576
SC_DLLPUBLIC void InitClipPtrs(ScDocument *pSourceDoc)
Definition: documen2.cxx:435
bool bIsVisible
Definition: document.hxx:496
void EndChangeTracking()
Definition: documen2.cxx:287
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:317
std::unique_ptr< ScChartListenerCollection > pChartListenerCollection
Definition: document.hxx:390
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:559
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
Definition: global.cxx:1053
static sc::SharedStringPoolPurge & GetSharedStringPoolPurge()
Definition: global.cxx:1139
static void ClearLookupCaches(const ScDocument *pDoc)
Lookup cache for one range used with interpreter functions such as VLOOKUP and MATCH.
Definition: lookupcache.hxx:40
const ScRange & getRange() const
ScLookupCacheMap & getCacheMap() const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
SCTAB GetFirstSelected() const
Definition: markdata.cxx:185
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:169
bool IsCellMarked(SCCOL nCol, SCROW nRow, bool bNoSimple=false) const
Definition: markdata.cxx:270
static void FillToEditItemSet(SfxItemSet &rEditSet, const SfxItemSet &rSrcSet, const SfxItemSet *pCondSet=nullptr)
Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet.
Definition: patattr.cxx:601
SfxItemSet & GetItemSet()
Definition: patattr.hxx:155
void CopyUsedNames(const SCTAB nLocalTab, const SCTAB nOldTab, const SCTAB nNewTab, const ScDocument &rOldDoc, ScDocument &rNewDoc, const bool bGlobalNamesToLocal) const
Copy names while copying a sheet if they reference the sheet to be copied.
Definition: rangenam.cxx:786
ScAddress aEnd
Definition: address.hxx:498
bool Contains(const ScAddress &) const
is Address& fully in Range?
Definition: address.hxx:718
ScAddress aStart
Definition: address.hxx:497
Sorted cache for one range used with interpreter functions such as VLOOKUP and MATCH.
Definition: rangecache.hxx:45
HashKey getHashKey() const
Definition: rangecache.hxx:77
static HashKey makeHashKey(const ScRange &range, const ScQueryParam &param)
Definition: rangecache.cxx:188
bool SetFormulaCells(SCCOL nCol, SCROW nRow, std::vector< ScFormulaCell * > &rCells)
Definition: table2.cxx:1746
Use this to lock all charts in the calc for a little time.
Definition: chartlock.hxx:53
SCROW GetMaxTiledRow() const
Definition: viewdata.hxx:423
SCCOL GetMaxTiledCol() const
Definition: viewdata.hxx:422
static bool IsActionShown(const ScChangeAction &rAction, const ScChangeViewSettings &rSettings, ScDocument &rDocument)
Definition: viewutil.cxx:135
void Invalidate(sal_uInt16 nId)
const INetURLObject & GetURLObject() const
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
BasicManager * GetBasicManager() const
SfxMedium * GetMedium() const
virtual void SetModified(bool bModified=true)
const OUString & GetName() const
bool IsActive() const
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void disposeAndClear()
static ThreadPool & getSharedOptimalPool()
Temporarily switch on/off auto calculation mode.
Definition: scopetools.hxx:27
Wrapper for ScDocument::EnableDelayDeletingBroadcasters()
Definition: scopetools.hxx:99
const sfx2::LinkManager * getExistingLinkManager() const
sfx2::LinkManager * getLinkManager(bool bCreate=true)
void delayedPurge(const std::shared_ptr< svl::SharedStringPool > &pool)
static bool IsFuzzing()
void VBA_InsertModule(ScDocument &rDoc, SCTAB nTab, const OUString &sSource)
Definition: docfunc.cxx:3197
IMPL_LINK_NOARG(ScDocument, TrackTimeHdl, Timer *, void)
Definition: documen2.cxx:303
#define SC_ASIANKERNING_INVALID
Definition: document.hxx:251
std::unique_ptr< ScTable, o3tl::default_delete< ScTable > > ScTableUniquePtr
Definition: document.hxx:319
ScDocumentMode
Definition: document.hxx:254
@ SCDOCMODE_CLIP
Definition: document.hxx:256
@ SCDOCMODE_UNDO
Definition: document.hxx:257
@ SCDOCMODE_DOCUMENT
Definition: document.hxx:255
@ SCDOCMODE_FUNCTIONACCESS
Definition: document.hxx:258
@ CORE
Definition: document.hxx:316
FormulaError
DocumentType eType
@ URM_COPY
Definition: global.hxx:302
@ URM_REORDER
Definition: global.hxx:304
@ URM_INSDEL
Definition: global.hxx:301
@ LM_UNKNOWN
Definition: global.hxx:413
@ FORMULA
Cell notes.
OUString aName
Mode eMode
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< sal_Int32[]> pData
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
std::shared_ptr< T > make_shared(Args &&... args)
PyRef getCharClass(const Runtime &)
CAUTION! The following defines must be in the same namespace as the respective type.
std::map< OUString, BitmapEx > IconSetBitmapMap
Definition: document.hxx:216
These need to be in global namespace just like their respective types are.
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define SC_CURRENT_VERSION
Definition: rechead.hxx:37
#define SC_MOD()
Definition: scmod.hxx:249
sal_uIntPtr sal_uLong
std::unique_ptr< ScRecursionHelper > xRecursionHelper
Definition: document.hxx:308
std::unique_ptr< ScLookupCacheMap > mxScLookupCache
std::unordered_map< ScRange, std::unique_ptr< ScLookupCache >, ScLookupCache::Hash > aCacheMap
A pretty assertion that checks that the relevant bits in the @nFlags are not set on the document at e...
Definition: document.hxx:2758
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
static SC_DLLPUBLIC ScSheetLimits CreateDefault()
Definition: documen2.cxx:99
ScSheetLimits(SCCOL nMaxCol, SCROW nMaxRow)
Maximum addressable row.
Definition: sheetlimits.hxx:32
Store position data for column array storage.
Context for reference update during shifting, moving or copying of cell ranges.
UpdateRefMode meMode
update mode - insert/delete, copy, or move.
SCTAB mnTabDelta
Amount and direction of movement in the sheet direction.
ScRange maRange
Range of cells that are about to be moved for insert/delete/move modes.
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17