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();
389 mpDrawLayer.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
514std::unique_ptr<EditTextObject> ScDocument::CreateSharedStringTextObject( const svl::SharedString& rSS )
515{
516 /* TODO: Add shared string support to the edit engine to make this process
517 * simpler. */
518 ScFieldEditEngine& rEngine = GetEditEngine();
519 rEngine.SetTextCurrentDefaults( rSS.getString());
520 std::unique_ptr<EditTextObject> pObj( rEngine.CreateTextObject());
521 pObj->NormalizeString( GetSharedStringPool());
522 return pObj;
523}
524
525void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks )
526{
527 if (bIsClip)
528 {
529 InitClipPtrs(pSourceDoc);
530
531 for (SCTAB i = 0; i < static_cast<SCTAB>(pSourceDoc->maTabs.size()); i++)
532 if (pSourceDoc->maTabs[i])
533 if (!pMarks || pMarks->GetTableSelect(i))
534 {
535 OUString aString = pSourceDoc->maTabs[i]->GetName();
536 if ( i < static_cast<SCTAB>(maTabs.size()) )
537 {
538 maTabs[i].reset( new ScTable(*this, i, aString) );
539
540 }
541 else
542 {
543 if( i > static_cast<SCTAB>(maTabs.size()) )
544 {
545 maTabs.resize(i);
546 }
547 maTabs.emplace_back(new ScTable(*this, i, aString));
548 }
549 maTabs[i]->SetLayoutRTL( pSourceDoc->maTabs[i]->IsLayoutRTL() );
550 }
551 }
552 else
553 {
554 OSL_FAIL("ResetClip");
555 }
556}
557
558void ScDocument::ResetClip( ScDocument* pSourceDoc, SCTAB nTab )
559{
560 if (bIsClip)
561 {
562 InitClipPtrs(pSourceDoc);
563 if (nTab >= static_cast<SCTAB>(maTabs.size()))
564 {
565 maTabs.resize(nTab+1);
566 }
567 maTabs[nTab].reset( new ScTable(*this, nTab, "baeh") );
568 if (nTab < static_cast<SCTAB>(pSourceDoc->maTabs.size()) && pSourceDoc->maTabs[nTab])
569 maTabs[nTab]->SetLayoutRTL( pSourceDoc->maTabs[nTab]->IsLayoutRTL() );
570 }
571 else
572 {
573 OSL_FAIL("ResetClip");
574 }
575}
576
578{
579 bool bExtras = !bIsUndo; // Column-Widths, Row-Heights, Flags
580 if (o3tl::make_unsigned(nTab) >= maTabs.size())
581 maTabs.resize(nTab+1);
582
583 if (!maTabs[nTab])
584 maTabs[nTab].reset( new ScTable(*this, nTab, "temp", bExtras, bExtras) );
585}
586
588{
589 if (!TableExists(rPos.Tab()))
590 return ScRefCellValue(); // empty
591
592 return maTabs[rPos.Tab()]->GetRefCellValue(rPos.Col(), rPos.Row());
593}
594
596{
597 if (!TableExists(rPos.Tab()))
598 return ScRefCellValue(); // empty
599
600 return maTabs[rPos.Tab()]->GetRefCellValue(rPos.Col(), rPos.Row(), rBlockPos);
601}
602
604{
605 return *mpCellStringPool;
606}
607
609{
610 return *mpCellStringPool;
611}
612
613bool ScDocument::GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
614 bool bNotes) const
615{
616 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
617 {
618 bool bAny = maTabs[nTab]->GetPrintArea( rEndCol, rEndRow, bNotes, /*bCalcHiddens*/false);
619 if (mpDrawLayer)
620 {
621 ScRange aDrawRange(0,0,nTab, MaxCol(),MaxRow(),nTab);
622 if (DrawGetPrintArea( aDrawRange, true, true ))
623 {
624 if (aDrawRange.aEnd.Col()>rEndCol) rEndCol=aDrawRange.aEnd.Col();
625 if (aDrawRange.aEnd.Row()>rEndRow) rEndRow=aDrawRange.aEnd.Row();
626 bAny = true;
627 }
628 }
629 return bAny;
630 }
631
632 rEndCol = 0;
633 rEndRow = 0;
634 return false;
635}
636
637bool ScDocument::GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
638 SCCOL& rEndCol ) const
639{
640 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
641 {
642 bool bAny = maTabs[nTab]->GetPrintAreaHor( nStartRow, nEndRow, rEndCol );
643 if (mpDrawLayer)
644 {
645 ScRange aDrawRange(0,nStartRow,nTab, MaxCol(),nEndRow,nTab);
646 if (DrawGetPrintArea( aDrawRange, true, false ))
647 {
648 if (aDrawRange.aEnd.Col()>rEndCol) rEndCol=aDrawRange.aEnd.Col();
649 bAny = true;
650 }
651 }
652 return bAny;
653 }
654
655 rEndCol = 0;
656 return false;
657}
658
659bool ScDocument::GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
660 SCROW& rEndRow, bool bNotes ) const
661{
662 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
663 {
664 bool bAny = maTabs[nTab]->GetPrintAreaVer( nStartCol, nEndCol, rEndRow, bNotes );
665 if (mpDrawLayer)
666 {
667 ScRange aDrawRange(nStartCol,0,nTab, nEndCol,MaxRow(),nTab);
668 if (DrawGetPrintArea( aDrawRange, false, true ))
669 {
670 if (aDrawRange.aEnd.Row()>rEndRow) rEndRow=aDrawRange.aEnd.Row();
671 bAny = true;
672 }
673 }
674 return bAny;
675 }
676
677 rEndRow = 0;
678 return false;
679}
680
681bool ScDocument::GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const
682{
683 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
684 {
685 bool bAny = maTabs[nTab]->GetDataStart( rStartCol, rStartRow );
686 if (mpDrawLayer)
687 {
688 ScRange aDrawRange(0,0,nTab, MaxCol(),MaxRow(),nTab);
689 if (DrawGetPrintArea( aDrawRange, true, true ))
690 {
691 if (aDrawRange.aStart.Col()<rStartCol) rStartCol=aDrawRange.aStart.Col();
692 if (aDrawRange.aStart.Row()<rStartRow) rStartRow=aDrawRange.aStart.Row();
693 bAny = true;
694 }
695 }
696 return bAny;
697 }
698
699 rStartCol = 0;
700 rStartRow = 0;
701 return false;
702}
703
704void ScDocument::GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const
705{
706 bool bHasPrintArea = GetPrintArea(nTab, rEndCol, rEndRow, false);
707
708 // we need some reasonable minimal document size
709 ScViewData* pViewData = ScDocShell::GetViewData();
710 if (!pViewData)
711 {
712 if (!bHasPrintArea)
713 {
714 rEndCol = 20;
715 rEndRow = 50;
716 }
717 else
718 {
719 rEndCol += 20;
720 rEndRow += 50;
721 }
722 }
723 else if (!bHasPrintArea)
724 {
725 rEndCol = pViewData->GetMaxTiledCol();
726 rEndRow = pViewData->GetMaxTiledRow();
727 }
728 else
729 {
730 rEndCol = std::max(rEndCol, pViewData->GetMaxTiledCol());
731 rEndRow = std::max(rEndRow, pViewData->GetMaxTiledRow());
732 }
733}
734
735bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
736{
737 if (nOldPos == nNewPos)
738 return false;
739
740 SCTAB nTabCount = static_cast<SCTAB>(maTabs.size());
741 if(nTabCount < 2)
742 return false;
743
744 bool bValid = false;
745 if (ValidTab(nOldPos) && nOldPos < nTabCount )
746 {
747 if (maTabs[nOldPos])
748 {
749 sc::AutoCalcSwitch aACSwitch(*this, false);
750 sc::DelayDeletingBroadcasters delayDeletingBroadcasters(*this);
751
752 SetNoListening( true );
753 if (nNewPos == SC_TAB_APPEND || nNewPos >= nTabCount)
754 nNewPos = nTabCount-1;
755
756 // Update Reference
757 // TODO: combine with UpdateReference!
758
759 sc::RefUpdateMoveTabContext aCxt( *this, nOldPos, nNewPos);
760
761 SCTAB nDz = nNewPos - nOldPos;
762 ScRange aSourceRange( 0,0,nOldPos, MaxCol(),MaxRow(),nOldPos );
763 if (pRangeName)
764 pRangeName->UpdateMoveTab(aCxt);
765
766 pDBCollection->UpdateMoveTab( nOldPos, nNewPos );
767 xColNameRanges->UpdateReference( URM_REORDER, this, aSourceRange, 0,0,nDz );
768 xRowNameRanges->UpdateReference( URM_REORDER, this, aSourceRange, 0,0,nDz );
769 if (pDPCollection)
770 pDPCollection->UpdateReference( URM_REORDER, aSourceRange, 0,0,nDz );
771 if (pDetOpList)
772 pDetOpList->UpdateReference( this, URM_REORDER, aSourceRange, 0,0,nDz );
774 0,0,nOldPos, MaxCol(),MaxRow(),nOldPos, 0,0,nDz );
775 UpdateRefAreaLinks( URM_REORDER, aSourceRange, 0,0,nDz );
776 if ( pValidationList )
777 pValidationList->UpdateMoveTab(aCxt);
778 if ( pUnoBroadcaster )
780 aSourceRange, 0,0,nDz ) );
781
782 ScTableUniquePtr pSaveTab = std::move(maTabs[nOldPos]);
783 maTabs.erase(maTabs.begin()+nOldPos);
784 maTabs.insert(maTabs.begin()+nNewPos, std::move(pSaveTab));
785 for (SCTAB i = 0; i < nTabCount; i++)
786 if (maTabs[i])
787 maTabs[i]->UpdateMoveTab(aCxt, i, pProgress);
788 for (auto& rxTab : maTabs)
789 if (rxTab)
790 rxTab->UpdateCompile();
791 SetNoListening( false );
793
794 sc::SetFormulaDirtyContext aFormulaDirtyCxt;
795 SetAllFormulasDirty(aFormulaDirtyCxt);
796
797 if (mpDrawLayer)
798 mpDrawLayer->ScMovePage( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) );
799
800 bValid = true;
801 }
802 }
803 return bValid;
804}
805
806bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyMarked )
807{
808 if (SC_TAB_APPEND == nNewPos || nNewPos >= static_cast<SCTAB>(maTabs.size()))
809 nNewPos = static_cast<SCTAB>(maTabs.size());
810 OUString aName;
811 GetName(nOldPos, aName);
812
813 // check first if Prefix is valid; if not, then only avoid duplicates
814 bool bPrefix = ValidTabName( aName );
815 OSL_ENSURE(bPrefix, "invalid table name");
816 SCTAB nDummy;
817
819
820 bool bValid;
821 if (bPrefix)
822 bValid = ValidNewTabName(aName);
823 else
824 bValid = !GetTable( aName, nDummy );
825
826 sc::AutoCalcSwitch aACSwitch(*this, false);
827 sc::RefUpdateInsertTabContext aCxt( *this, nNewPos, 1);
828
829 if (bValid)
830 {
831 if (nNewPos >= static_cast<SCTAB>(maTabs.size()))
832 {
833 nNewPos = static_cast<SCTAB>(maTabs.size());
834 maTabs.emplace_back(new ScTable(*this, nNewPos, aName));
835 }
836 else
837 {
838 if (ValidTab(nNewPos) && (nNewPos < static_cast<SCTAB>(maTabs.size())))
839 {
840 SetNoListening( true );
841
842 ScRange aRange( 0,0,nNewPos, MaxCol(),MaxRow(),MAXTAB );
843 xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 );
844 xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 );
845 if (pRangeName)
846 pRangeName->UpdateInsertTab(aCxt);
847
848 pDBCollection->UpdateReference(
849 URM_INSDEL, 0,0,nNewPos, MaxCol(),MaxRow(),MAXTAB, 0,0,1 );
850 if (pDPCollection)
851 pDPCollection->UpdateReference( URM_INSDEL, aRange, 0,0,1 );
852 if (pDetOpList)
853 pDetOpList->UpdateReference( this, URM_INSDEL, aRange, 0,0,1 );
854 UpdateChartRef( URM_INSDEL, 0,0,nNewPos, MaxCol(),MaxRow(),MAXTAB, 0,0,1 );
855 UpdateRefAreaLinks( URM_INSDEL, aRange, 0,0,1 );
856 if ( pUnoBroadcaster )
857 pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,1 ) );
858
859 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
860 if (*it && it != (maTabs.begin() + nOldPos))
861 (*it)->UpdateInsertTab(aCxt);
862 if (nNewPos <= nOldPos)
863 nOldPos++;
864 maTabs.emplace(maTabs.begin() + nNewPos, new ScTable(*this, nNewPos, aName));
865 bValid = true;
866 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
867 if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin() + nNewPos)
868 (*it)->UpdateCompile();
869 SetNoListening( false );
870 sc::StartListeningContext aSLCxt(*this);
871 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
872 if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin()+nNewPos)
873 (*it)->StartListeners(aSLCxt, true);
874
875 if (pValidationList)
876 pValidationList->UpdateInsertTab(aCxt);
877 }
878 else
879 bValid = false;
880 }
881 }
882
883 if (bValid)
884 {
885 SetNoListening( true ); // not yet at CopyToTable/Insert
886
887 const bool bGlobalNamesToLocal = true;
888 const SCTAB nRealOldPos = (nNewPos < nOldPos) ? nOldPos - 1 : nOldPos;
889 const ScRangeName* pNames = GetRangeName( nOldPos);
890 if (pNames)
891 pNames->CopyUsedNames( nOldPos, nRealOldPos, nNewPos, *this, *this, bGlobalNamesToLocal);
892 GetRangeName()->CopyUsedNames( -1, nRealOldPos, nNewPos, *this, *this, bGlobalNamesToLocal);
893
894 sc::CopyToDocContext aCopyDocCxt(*this);
895 pDBCollection->CopyToTable(nOldPos, nNewPos);
896 maTabs[nOldPos]->CopyToTable(aCopyDocCxt, 0, 0, MaxCol(), MaxRow(), InsertDeleteFlags::ALL,
897 (pOnlyMarked != nullptr), maTabs[nNewPos].get(), pOnlyMarked,
898 false /*bAsLink*/, true /*bColRowFlags*/, bGlobalNamesToLocal, false /*bCopyCaptions*/ );
899 maTabs[nNewPos]->SetTabBgColor(maTabs[nOldPos]->GetTabBgColor());
900
901 SCTAB nDz = nNewPos - nOldPos;
902 sc::RefUpdateContext aRefCxt(*this);
903 aRefCxt.meMode = URM_COPY;
904 aRefCxt.maRange = ScRange(0, 0, nNewPos, MaxCol(), MaxRow(), nNewPos);
905 aRefCxt.mnTabDelta = nDz;
906 maTabs[nNewPos]->UpdateReference(aRefCxt);
907
908 maTabs[nNewPos]->UpdateInsertTabAbs(nNewPos); // move all paragraphs up by one!!
909 maTabs[nOldPos]->UpdateInsertTab(aCxt);
910
911 maTabs[nOldPos]->UpdateCompile();
912 maTabs[nNewPos]->UpdateCompile( true ); // maybe already compiled in Clone, but used names need recompilation
913 SetNoListening( false );
914 sc::StartListeningContext aSLCxt(*this);
915 maTabs[nOldPos]->StartListeners(aSLCxt, true);
916 maTabs[nNewPos]->StartListeners(aSLCxt, true);
917
918 sc::SetFormulaDirtyContext aFormulaDirtyCxt;
919 SetAllFormulasDirty(aFormulaDirtyCxt);
920
921 if (mpDrawLayer) // Skip cloning Note caption object
922 // page is already created in ScTable ctor
923 mpDrawLayer->ScCopyPage( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) );
924
925 if (pDPCollection)
926 pDPCollection->CopyToTab(nOldPos, nNewPos);
927
928 maTabs[nNewPos]->SetPageStyle( maTabs[nOldPos]->GetPageStyle() );
929 maTabs[nNewPos]->SetPendingRowHeights( maTabs[nOldPos]->IsPendingRowHeights() );
930
931 // Copy the custom print range if exists.
932 maTabs[nNewPos]->CopyPrintRange(*maTabs[nOldPos]);
933
934 // Copy the RTL settings
935 maTabs[nNewPos]->SetLayoutRTL(maTabs[nOldPos]->IsLayoutRTL());
936 maTabs[nNewPos]->SetLoadingRTL(maTabs[nOldPos]->IsLoadingRTL());
937
938 // Finally copy the note captions, which need
939 // 1. the updated source ScColumn::nTab members if nNewPos <= nOldPos
940 // 2. row heights and column widths of the destination
941 // 3. RTL settings of the destination
942 maTabs[nOldPos]->CopyCaptionsToTable( 0, 0, MaxCol(), MaxRow(), maTabs[nNewPos].get(), true /*bCloneCaption*/);
943 }
944
945 return bValid;
946}
947
949 SCTAB nDestPos, bool bInsertNew,
950 bool bResultsOnly )
951{
952 sal_uLong nRetVal = 1; // 0 => error 1 = ok
953 // 3 => NameBox
954 // 4 => both
955
956 if (rSrcDoc.mpShell->GetMedium())
957 {
959 // for unsaved files use the title name and adjust during save of file
960 if (rSrcDoc.maFileURL.isEmpty())
961 rSrcDoc.maFileURL = rSrcDoc.mpShell->GetName();
962 }
963 else
964 {
965 rSrcDoc.maFileURL = rSrcDoc.mpShell->GetName();
966 }
967
968 bool bValid = true;
969 if (bInsertNew) // re-insert
970 {
971 OUString aName;
972 rSrcDoc.GetName(nSrcPos, aName);
974 bValid = InsertTab(nDestPos, aName);
975
976 // Copy the RTL settings
977 maTabs[nDestPos]->SetLayoutRTL(rSrcDoc.maTabs[nSrcPos]->IsLayoutRTL());
978 maTabs[nDestPos]->SetLoadingRTL(rSrcDoc.maTabs[nSrcPos]->IsLoadingRTL());
979 }
980 else // replace existing tables
981 {
982 if (ValidTab(nDestPos) && nDestPos < static_cast<SCTAB>(maTabs.size()) && maTabs[nDestPos])
983 {
984 maTabs[nDestPos]->DeleteArea( 0,0, MaxCol(),MaxRow(), InsertDeleteFlags::ALL );
985 }
986 else
987 bValid = false;
988 }
989
990 if (bValid)
991 {
992 bool bOldAutoCalcSrc = false;
993 bool bOldAutoCalc = GetAutoCalc();
994 SetAutoCalc( false ); // avoid repeated calculations
995 SetNoListening( true );
996 if ( bResultsOnly )
997 {
998 bOldAutoCalcSrc = rSrcDoc.GetAutoCalc();
999 rSrcDoc.SetAutoCalc( true ); // in case something needs calculation
1000 }
1001
1002 {
1003 NumFmtMergeHandler aNumFmtMergeHdl(*this, rSrcDoc);
1004
1005 sc::CopyToDocContext aCxt(*this);
1006 nDestPos = std::min(nDestPos, static_cast<SCTAB>(GetTableCount() - 1));
1007 { // scope for bulk broadcast
1008 ScBulkBroadcast aBulkBroadcast( pBASM.get(), SfxHintId::ScDataChanged);
1009 if (!bResultsOnly)
1010 {
1011 const bool bGlobalNamesToLocal = false;
1012 const ScRangeName* pNames = rSrcDoc.GetRangeName( nSrcPos);
1013 if (pNames)
1014 pNames->CopyUsedNames( nSrcPos, nSrcPos, nDestPos, rSrcDoc, *this, bGlobalNamesToLocal);
1015 rSrcDoc.GetRangeName()->CopyUsedNames( -1, nSrcPos, nDestPos, rSrcDoc, *this, bGlobalNamesToLocal);
1016 }
1017 rSrcDoc.maTabs[nSrcPos]->CopyToTable(aCxt, 0, 0, MaxCol(), MaxRow(),
1019 false, maTabs[nDestPos].get(), /*pMarkData*/nullptr, /*bAsLink*/false, /*bColRowFlags*/true,
1020 /*bGlobalNamesToLocal*/false, /*bCopyCaptions*/true );
1021 }
1022 }
1023 maTabs[nDestPos]->SetTabNo(nDestPos);
1024 maTabs[nDestPos]->SetTabBgColor(rSrcDoc.maTabs[nSrcPos]->GetTabBgColor());
1025
1026 // tdf#66613 - copy existing print ranges and col/row repetitions
1027 if (auto aRepeatColRange = rSrcDoc.maTabs[nSrcPos]->GetRepeatColRange())
1028 {
1029 aRepeatColRange->aStart.SetTab(nDestPos);
1030 aRepeatColRange->aEnd.SetTab(nDestPos);
1031 maTabs[nDestPos]->SetRepeatColRange(aRepeatColRange);
1032 }
1033
1034 if (auto aRepeatRowRange = rSrcDoc.maTabs[nSrcPos]->GetRepeatRowRange())
1035 {
1036 aRepeatRowRange->aStart.SetTab(nDestPos);
1037 aRepeatRowRange->aEnd.SetTab(nDestPos);
1038 maTabs[nDestPos]->SetRepeatRowRange(aRepeatRowRange);
1039 }
1040
1041 if (rSrcDoc.IsPrintEntireSheet(nSrcPos))
1042 maTabs[nDestPos]->SetPrintEntireSheet();
1043 else
1044 {
1045 const auto nPrintRangeCount = rSrcDoc.maTabs[nSrcPos]->GetPrintRangeCount();
1046 for (auto nPos = 0; nPos < nPrintRangeCount; nPos++)
1047 {
1048 // Adjust the tab for the print range at the new position
1049 ScRange aSrcPrintRange(*rSrcDoc.maTabs[nSrcPos]->GetPrintRange(nPos));
1050 aSrcPrintRange.aStart.SetTab(nDestPos);
1051 aSrcPrintRange.aEnd.SetTab(nDestPos);
1052 maTabs[nDestPos]->AddPrintRange(aSrcPrintRange);
1053 }
1054 }
1055
1056 if ( !bResultsOnly )
1057 {
1058 sc::RefUpdateContext aRefCxt(*this);
1059 aRefCxt.meMode = URM_COPY;
1060 aRefCxt.maRange = ScRange(0, 0, nDestPos, MaxCol(), MaxRow(), nDestPos);
1061 aRefCxt.mnTabDelta = nDestPos - nSrcPos;
1062 maTabs[nDestPos]->UpdateReference(aRefCxt);
1063
1064 // Readjust self-contained absolute references to this sheet
1065 maTabs[nDestPos]->TestTabRefAbs(nSrcPos);
1066 sc::CompileFormulaContext aFormulaCxt(*this);
1067 maTabs[nDestPos]->CompileAll(aFormulaCxt);
1068 }
1069
1070 SetNoListening( false );
1071 if ( !bResultsOnly )
1072 {
1073 sc::StartListeningContext aSLCxt(*this);
1074 maTabs[nDestPos]->StartListeners(aSLCxt, true);
1075 }
1076 SetDirty( ScRange( 0, 0, nDestPos, MaxCol(), MaxRow(), nDestPos), false);
1077
1078 if ( bResultsOnly )
1079 rSrcDoc.SetAutoCalc( bOldAutoCalcSrc );
1080 SetAutoCalc( bOldAutoCalc );
1081
1082 // copy Drawing
1083
1084 if (bInsertNew)
1085 TransferDrawPage( rSrcDoc, nSrcPos, nDestPos );
1086
1087 maTabs[nDestPos]->SetPendingRowHeights( rSrcDoc.maTabs[nSrcPos]->IsPendingRowHeights() );
1088 }
1089 if (!bValid)
1090 nRetVal = 0;
1091 bool bVbaEnabled = IsInVBAMode();
1092
1093 if ( bVbaEnabled )
1094 {
1095 SfxObjectShell* pSrcShell = rSrcDoc.GetDocumentShell();
1096 if ( pSrcShell )
1097 {
1098 OUString aLibName("Standard");
1099#if HAVE_FEATURE_SCRIPTING
1100 const BasicManager *pBasicManager = pSrcShell->GetBasicManager();
1101 if (pBasicManager && !pBasicManager->GetName().isEmpty())
1102 {
1103 aLibName = pSrcShell->GetBasicManager()->GetName();
1104 }
1105#endif
1106 OUString sSource;
1107 uno::Reference< script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer();
1108 uno::Reference< container::XNameContainer > xLib;
1109 if( xLibContainer.is() )
1110 {
1111 uno::Any aLibAny = xLibContainer->getByName(aLibName);
1112 aLibAny >>= xLib;
1113 }
1114
1115 if( xLib.is() )
1116 {
1117 OUString sSrcCodeName;
1118 rSrcDoc.GetCodeName( nSrcPos, sSrcCodeName );
1119 OUString sRTLSource;
1120 xLib->getByName( sSrcCodeName ) >>= sRTLSource;
1121 sSource = sRTLSource;
1122 }
1123 VBA_InsertModule( *this, nDestPos, sSource );
1124 }
1125 }
1126
1127 return nRetVal;
1128}
1129
1130void ScDocument::SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError)
1131{
1132 if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
1133 if (maTabs[nTab])
1134 maTabs[nTab]->SetError( nCol, nRow, nError );
1135}
1136
1138 const ScAddress& rPos, const ScTokenArray& rArray )
1139{
1140 if (!TableExists(rPos.Tab()))
1141 return;
1142
1143 maTabs[rPos.Tab()]->SetFormula(rPos.Col(), rPos.Row(), rArray, formula::FormulaGrammar::GRAM_DEFAULT);
1144}
1145
1147 const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram )
1148{
1149 if (!TableExists(rPos.Tab()))
1150 return;
1151
1152 maTabs[rPos.Tab()]->SetFormula(rPos.Col(), rPos.Row(), rFormula, eGram);
1153}
1154
1156{
1157 if (!TableExists(rPos.Tab()))
1158 {
1159 delete pCell;
1160 return nullptr;
1161 }
1162
1163 return maTabs[rPos.Tab()]->SetFormulaCell(rPos.Col(), rPos.Row(), pCell);
1164}
1165
1166bool ScDocument::SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells )
1167{
1168 if (rCells.empty())
1169 return false;
1170
1171 ScTable* pTab = FetchTable(rPos.Tab());
1172 if (!pTab)
1173 return false;
1174
1175 return pTab->SetFormulaCells(rPos.Col(), rPos.Row(), rCells);
1176}
1177
1178void ScDocument::SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData )
1179{
1180 pConsolidateDlgData = std::move(pData);
1181}
1182
1184{
1185 if (pChangeViewSettings==nullptr)
1187
1188 *pChangeViewSettings=rNew;
1189}
1190
1191std::unique_ptr<ScFieldEditEngine> ScDocument::CreateFieldEditEngine()
1192{
1193 std::unique_ptr<ScFieldEditEngine> pNewEditEngine;
1195 {
1196 pNewEditEngine.reset( new ScFieldEditEngine(
1197 this, GetEnginePool(), GetEditPool(), false) );
1198 }
1199 else
1200 {
1201 if ( !bImportingXML )
1202 {
1203 // #i66209# previous use might not have restored update mode,
1204 // ensure same state as for a new EditEngine (UpdateMode = true)
1205 pCacheFieldEditEngine->SetUpdateLayout(true);
1206 }
1207
1208 pNewEditEngine = std::move(pCacheFieldEditEngine);
1209 }
1210 return pNewEditEngine;
1211}
1212
1213void ScDocument::DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine)
1214{
1215 if (!pCacheFieldEditEngine && rpEditEngine)
1216 {
1217 pCacheFieldEditEngine = std::move( rpEditEngine );
1218 pCacheFieldEditEngine->Clear();
1219 }
1220 else
1221 rpEditEngine.reset();
1222}
1223
1225{
1226 ScLookupCache* pCache = nullptr;
1227 if (!pContext->mxScLookupCache)
1228 pContext->mxScLookupCache.reset(new ScLookupCacheMap);
1229 ScLookupCacheMap* pCacheMap = pContext->mxScLookupCache.get();
1230 // insert with temporary value to avoid doing two lookups
1231 auto [findIt, bInserted] = pCacheMap->aCacheMap.emplace(rRange, nullptr);
1232 if (bInserted)
1233 {
1234 findIt->second = std::make_unique<ScLookupCache>(this, rRange, *pCacheMap);
1235 pCache = findIt->second.get();
1236 // The StartListeningArea() call is not thread-safe, as all threads
1237 // would access the same SvtBroadcaster.
1238 std::unique_lock guard( mScLookupMutex );
1239 StartListeningArea(rRange, false, pCache);
1240 }
1241 else
1242 pCache = (*findIt).second.get();
1243
1244 return *pCache;
1245}
1246
1248 ScInterpreterContext* pContext )
1249{
1250 assert(mxScSortedRangeCache);
1252 // This should be created just once for one range, and repeated calls should reuse it, even
1253 // between threads (it doesn't make sense to use ScInterpreterContext and have all threads
1254 // build their own copy of the same data). So first try read-only access, which should
1255 // in most cases be enough.
1256 {
1257 std::shared_lock guard(mScLookupMutex);
1258 auto findIt = mxScSortedRangeCache->aCacheMap.find(key);
1259 if( findIt != mxScSortedRangeCache->aCacheMap.end())
1260 return *findIt->second;
1261 }
1262 // Avoid recursive calls because of some cells in the range being dirty and triggering
1263 // interpreting, which may call into this again. Threaded calculation makes sure
1264 // no cells are dirty. If some cells in the range cannot be interpreted and remain
1265 // dirty e.g. because of circular dependencies, create only an invalid empty cache to prevent
1266 // a possible recursive deadlock.
1267 bool invalid = false;
1269 if(!InterpretCellsIfNeeded(rRange))
1270 invalid = true;
1271 std::unique_lock guard(mScLookupMutex);
1272 auto [findIt, bInserted] = mxScSortedRangeCache->aCacheMap.emplace(key, nullptr);
1273 if (bInserted)
1274 {
1275 findIt->second = std::make_unique<ScSortedRangeCache>(this, rRange, param, pContext, invalid);
1276 StartListeningArea(rRange, false, findIt->second.get());
1277 }
1278 return *findIt->second;
1279}
1280
1282{
1283 // Data changes leading to this should never happen during calculation (they are either
1284 // a result of user input or recalc). If it turns out this can be the case, locking is needed
1285 // here and also in ScLookupCache::Notify().
1287 auto & cacheMap = rCache.getCacheMap();
1288 auto it(cacheMap.aCacheMap.find(rCache.getRange()));
1289 if (it != cacheMap.aCacheMap.end())
1290 {
1291 std::unique_ptr<ScLookupCache> xCache = std::move(it->second);
1292 cacheMap.aCacheMap.erase(it);
1293 assert(!IsThreadedGroupCalcInProgress()); // EndListeningArea() is not thread-safe
1294 EndListeningArea(xCache->getRange(), false, &rCache);
1295 return;
1296 }
1297 OSL_FAIL( "ScDocument::RemoveLookupCache: range not found in hash map");
1298}
1299
1301{
1302 // Data changes leading to this should never happen during calculation (they are either
1303 // a result of user input or recalc). If it turns out this can be the case, locking is needed
1304 // here and also in ScSortedRangeCache::Notify().
1306 auto it(mxScSortedRangeCache->aCacheMap.find(rCache.getHashKey()));
1307 if (it != mxScSortedRangeCache->aCacheMap.end())
1308 {
1309 std::unique_ptr<ScSortedRangeCache> xCache = std::move(it->second);
1310 mxScSortedRangeCache->aCacheMap.erase(it);
1311 assert(!IsThreadedGroupCalcInProgress()); // EndListeningArea() is not thread-safe
1312 EndListeningArea(xCache->getRange(), false, &rCache);
1313 return;
1314 }
1315 OSL_FAIL( "ScDocument::RemoveSortedRangeCache: range not found in hash map");
1316}
1317
1319{
1322 mxScSortedRangeCache->aCacheMap.clear();
1323 // Clear lookup cache in all interpreter-contexts in the (threaded/non-threaded) pools.
1325}
1326
1327bool ScDocument::IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder)
1328{
1329 ScChangeTrack* pTrack = GetChangeTrack();
1331 if ( !pTrack || !pTrack->GetFirst() || !pSettings || !pSettings->ShowChanges() )
1332 return false; // missing or turned-off
1333 ScActionColorChanger aColorChanger(*pTrack);
1334 // Clipping happens from outside
1336 const ScChangeAction* pAction = pTrack->GetFirst();
1337 while (pAction)
1338 {
1339 if ( pAction->IsVisible() )
1340 {
1341 ScChangeActionType eType = pAction->GetType();
1342 const ScBigRange& rBig = pAction->GetBigRange();
1343 if ( rBig.aStart.Tab() == cell.Tab())
1344 {
1345 ScRange aRange = rBig.MakeRange( *this );
1346 if ( eType == SC_CAT_DELETE_ROWS )
1347 aRange.aEnd.SetRow( aRange.aStart.Row() );
1348 else if ( eType == SC_CAT_DELETE_COLS )
1349 aRange.aEnd.SetCol( aRange.aStart.Col() );
1350 if (ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
1351 {
1352 if (aRange.Contains(cell))
1353 {
1354 if (pColCellBorder != nullptr)
1355 {
1356 aColorChanger.Update( *pAction );
1357 Color aColor( aColorChanger.GetColor() );
1358 *pColCellBorder = aColor;
1359 }
1360 return true;
1361 }
1362 }
1363 }
1364 if ( eType == SC_CAT_MOVE &&
1365 static_cast<const ScChangeActionMove*>(pAction)->
1366 GetFromRange().aStart.Tab() == cell.Col() )
1367 {
1368 ScRange aRange = static_cast<const ScChangeActionMove*>(pAction)->
1369 GetFromRange().MakeRange( *this );
1370 if (ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
1371 {
1372 if (aRange.Contains(cell))
1373 {
1374 if (pColCellBorder != nullptr)
1375 {
1376 aColorChanger.Update( *pAction );
1377 Color aColor( aColorChanger.GetColor() );
1378 *pColCellBorder = aColor;
1379 }
1380 return true;
1381 }
1382 }
1383 }
1384 }
1385 pAction = pAction->GetNext();
1386 }
1387 return false;
1388}
1389
1390void ScDocument::GetCellChangeTrackNote( const ScAddress &aCellPos, OUString &aTrackText,bool &bLeftEdge)
1391{
1392 aTrackText.clear();
1393 // Change-Tracking
1394 ScChangeTrack* pTrack = GetChangeTrack();
1396 if ( !(pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges()))
1397 return;
1398
1399 const ScChangeAction* pFound = nullptr;
1400 const ScChangeAction* pFoundContent = nullptr;
1401 const ScChangeAction* pFoundMove = nullptr;
1402 const ScChangeAction* pAction = pTrack->GetFirst();
1403 while (pAction)
1404 {
1405 if ( pAction->IsVisible() &&
1406 ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
1407 {
1408 ScChangeActionType eType = pAction->GetType();
1409 const ScBigRange& rBig = pAction->GetBigRange();
1410 if ( rBig.aStart.Tab() == aCellPos.Tab())
1411 {
1412 ScRange aRange = rBig.MakeRange( *this );
1413 if ( eType == SC_CAT_DELETE_ROWS )
1414 aRange.aEnd.SetRow( aRange.aStart.Row() );
1415 else if ( eType == SC_CAT_DELETE_COLS )
1416 aRange.aEnd.SetCol( aRange.aStart.Col() );
1417 if ( aRange.Contains( aCellPos ) )
1418 {
1419 pFound = pAction; // the last wins
1420 switch ( eType )
1421 {
1422 case SC_CAT_CONTENT :
1423 pFoundContent = pAction;
1424 break;
1425 case SC_CAT_MOVE :
1426 pFoundMove = pAction;
1427 break;
1428 default:
1429 break;
1430 }
1431 }
1432 }
1433 if ( eType == SC_CAT_MOVE )
1434 {
1435 ScRange aRange =
1436 static_cast<const ScChangeActionMove*>(pAction)->
1437 GetFromRange().MakeRange( *this );
1438 if ( aRange.Contains( aCellPos ) )
1439 {
1440 pFound = pAction;
1441 }
1442 }
1443 }
1444 pAction = pAction->GetNext();
1445 }
1446 if ( !pFound )
1447 return;
1448
1449 if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT )
1450 pFound = pFoundContent; // Content wins
1451 if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE &&
1452 pFoundMove->GetActionNumber() >
1453 pFound->GetActionNumber() )
1454 pFound = pFoundMove; // Move wins
1455 // for deleted columns: arrow on left side of row
1456 if ( pFound->GetType() == SC_CAT_DELETE_COLS )
1457 bLeftEdge = true;
1458 DateTime aDT = pFound->GetDateTime();
1459 aTrackText = pFound->GetUser();
1460 aTrackText += ", ";
1461 aTrackText += ScGlobal::getLocaleData().getDate(aDT);
1462 aTrackText += " ";
1463 aTrackText += ScGlobal::getLocaleData().getTime(aDT);
1464 aTrackText += ":\n";
1465 OUString aComStr = pFound->GetComment();
1466 if(!aComStr.isEmpty())
1467 {
1468 aTrackText += aComStr;
1469 aTrackText += "\n( ";
1470 }
1471 aTrackText = pFound->GetDescription( *this );
1472 if (!aComStr.isEmpty())
1473 {
1474 aTrackText += ")";
1475 }
1476}
1477
1478void ScDocument::SetPreviewFont( std::unique_ptr<SfxItemSet> pFont )
1479{
1480 pPreviewFont = std::move(pFont);
1481}
1482
1484{
1485 maPreviewSelection = rSel;
1486}
1487
1489{
1490 SfxItemSet* pRet = nullptr;
1491 if ( pPreviewFont )
1492 {
1494 if ( aSel.IsCellMarked( nCol, nRow ) && aSel.GetFirstSelected() == nTab )
1495 pRet = pPreviewFont.get();
1496 }
1497 return pRet;
1498}
1499
1501{
1502 ScStyleSheet* pRet = nullptr;
1504 if ( pPreviewCellStyle && aSel.IsCellMarked( nCol, nRow ) && aSel.GetFirstSelected() == nTab )
1505 pRet = pPreviewCellStyle;
1506 return pRet;
1507}
1508
1510{
1512 {
1514 }
1515 return *m_pIconSetBitmapMap;
1516}
1517
1518/* 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
const OUString & GetName() const
std::unique_ptr< EditTextObject > CreateTextObject()
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
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
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:249
const OUString & GetComment() const
Definition: chgtrack.hxx:348
ScBigRange & GetBigRange()
Definition: chgtrack.hxx:229
bool IsVisible() const
Definition: chgtrack.cxx:143
sal_uLong GetActionNumber() const
Definition: chgtrack.hxx:317
ScChangeActionType GetType() const
Definition: chgtrack.hxx:315
virtual OUString GetDescription(ScDocument &rDoc, bool bSplitRange=false, bool bWarning=true) const
Definition: chgtrack.cxx:421
ScChangeAction * GetNext() const
Definition: chgtrack.hxx:320
SC_DLLPUBLIC DateTime GetDateTime() const
Definition: chgtrack.cxx:407
const OUString & GetUser() const
Definition: chgtrack.hxx:347
ScChangeAction * GetFirst() const
Definition: chgtrack.hxx:951
bool ShowChanges() const
Definition: chgviset.hxx:77
static ScViewData * GetViewData()
Definition: docsh4.cxx:2593
Use this class as a locale variable to merge number formatter from another document,...
Definition: document.hxx:2663
SC_DLLPUBLIC bool InsertTab(SCTAB nPos, const OUString &rName, bool bExternalDocument=false, bool bUndoDeleteTab=false)
Definition: document.cxx:505
void StartAllListeners()
Definition: documen7.cxx:588
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
Definition: documen2.cxx:478
std::shared_ptr< svl::SharedStringPool > mpCellStringPool
Definition: document.hxx:360
rtl::Reference< ScSheetLimits > mxSheetLimits
Definition: document.hxx:379
SC_DLLPUBLIC ~ScDocument()
Definition: documen2.cxx:346
friend class ScTable
Definition: document.hxx:339
std::unique_ptr< ScFieldEditEngine > pCacheFieldEditEngine
Definition: document.hxx:405
OUString maFileURL
Definition: document.hxx:419
bool IsCellInChangeTrack(const ScAddress &cell, Color *pColCellBorder)
Definition: documen2.cxx:1327
std::unique_ptr< SvMemoryStream > pClipData
Definition: document.hxx:392
bool bInLinkUpdate
Definition: document.hxx:510
std::unique_ptr< ScConsolidateParam > pConsolidateDlgData
Definition: document.hxx:427
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:1155
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:6182
std::unique_ptr< ScFieldEditEngine > mpEditEngine
Definition: document.hxx:369
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:491
bool bInDtorClear
Definition: document.hxx:515
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:948
SC_DLLPUBLIC ScTable * FetchTable(SCTAB nTab)
Definition: document.cxx:2535
std::unique_ptr< ScUnoListenerCalls > pUnoListenerCalls
Definition: document.hxx:396
SC_DLLPUBLIC void SetFormula(const ScAddress &rPos, const ScTokenArray &rArray)
Definition: documen2.cxx:1137
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:439
VclPtr< SfxPrinter > mpPrinter
Definition: document.hxx:372
std::unique_ptr< ScDBData > mpAnonymousDBData
Definition: document.hxx:402
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:432
bool SetFormulaCells(const ScAddress &rPos, std::vector< ScFormulaCell * > &rCells)
Definition: documen2.cxx:1166
ScDocumentThreadSpecific maNonThreaded
Definition: document.hxx:467
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
std::unique_ptr< SfxItemSet > pPreviewFont
Definition: document.hxx:431
std::unique_ptr< ScDPCollection > pDPCollection
Definition: document.hxx:383
SC_DLLPUBLIC bool GetPrintAreaVer(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW &rEndRow, bool bNotes) const
Definition: documen2.cxx:659
void SharePooledResources(const ScDocument *pSrcDoc)
Definition: document10.cxx:330
std::unique_ptr< ScSortedRangeCacheMap > mxScSortedRangeCache
Definition: document.hxx:476
std::unique_ptr< ScFormulaParserPool > mxFormulaParserPool
Definition: document.hxx:415
static const sal_uInt16 nSrcVer
Definition: document.hxx:478
rtl::Reference< ScPoolHelper > mxPoolHelper
Definition: document.hxx:358
static SC_DLLPUBLIC bool ValidTabName(const OUString &rName)
Definition: document.cxx:338
SC_DLLPUBLIC void EnsureTable(SCTAB nTab)
Definition: documen2.cxx:577
void SetExpandRefs(bool bVal)
Definition: documen2.cxx:327
std::unique_ptr< ScBroadcastAreaSlotMachine > pBASM
Definition: document.hxx:390
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
std::unique_ptr< ScChangeViewSettings > pChangeViewSettings
Definition: document.hxx:398
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:1247
std::unique_ptr< ScRefreshTimerControl > const & GetRefreshTimerControlAddress() const
Definition: document.hxx:2523
std::unique_ptr< ScAutoNameCache > pAutoNameCache
Definition: document.hxx:429
std::unique_ptr< ScPatternAttr > pSelectionAttr
Definition: document.hxx:385
ScLookupCache & GetLookupCache(const ScRange &rRange, ScInterpreterContext *pContext)
Creates a ScLookupCache cache for the range if it doesn't already exist.
Definition: documen2.cxx:1224
std::unique_ptr< SfxBroadcaster > pUnoBroadcaster
Definition: document.hxx:395
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:617
std::unique_ptr< ScValidationDataList > pValidationList
Definition: document.hxx:376
void SetConsolidateDlgData(std::unique_ptr< ScConsolidateParam > pData)
Definition: documen2.cxx:1178
void RemoveLookupCache(ScLookupCache &rCache)
Only ScLookupCache dtor uses RemoveLookupCache(), do not use elsewhere!
Definition: documen2.cxx:1281
ScRangePairListRef xRowNameRanges
Definition: document.hxx:421
bool bImportingXML
Definition: document.hxx:505
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:704
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
Definition: documen2.cxx:1183
std::unique_ptr< sc::DocumentLinkManager > mpDocLinkMgr
Definition: document.hxx:361
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:393
std::unique_ptr< ScFieldEditEngine > CreateFieldEditEngine()
Definition: documen2.cxx:1191
SC_DLLPUBLIC bool GetAutoCalc() const
Definition: document.hxx:1412
bool IsInVBAMode() const
Definition: document.cxx:6624
void SetLanguage(LanguageType eLatin, LanguageType eCjk, LanguageType eCtl)
Definition: documen3.cxx:1986
ScChangeViewSettings * GetChangeViewSettings() const
Definition: document.hxx:2244
void StartTrackTimer()
Definition: documen2.cxx:332
void StartChangeTracking()
Definition: documen2.cxx:277
bool bExpandRefs
Definition: document.hxx:520
TableContainer maTabs
Definition: document.hxx:378
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
Definition: document.cxx:6319
bool bIsClip
Definition: document.hxx:494
void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge)
Definition: documen2.cxx:1390
std::unique_ptr< ScExternalRefManager > pExternalRefMgr
Definition: document.hxx:410
void SetAllFormulasDirty(const sc::SetFormulaDirtyContext &rCxt)
Definition: document.cxx:3878
formula::FormulaGrammar::Grammar eStorageGrammar
The compiler grammar used in document storage.
Definition: document.hxx:459
SC_DLLPUBLIC bool GetPrintAreaHor(SCTAB nTab, SCROW nStartRow, SCROW nEndRow, SCCOL &rEndCol) const
Definition: documen2.cxx:637
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:946
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
Definition: document.cxx:395
std::unique_ptr< EditTextObject > CreateSharedStringTextObject(const svl::SharedString &rSS)
Definition: documen2.cxx:514
std::unique_ptr< ScChangeTrack > pChangeTrack
Definition: document.hxx:394
void DisposeFieldEditEngine(std::unique_ptr< ScFieldEditEngine > &rpEditEngine)
Definition: documen2.cxx:1213
std::unique_ptr< sc::IconSetBitmapMap > m_pIconSetBitmapMap
Definition: document.hxx:568
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
Definition: documen7.cxx:35
static thread_local ScDocumentThreadSpecific maThreadSpecific
Definition: document.hxx:471
friend struct ScRefCellValue
Definition: document.hxx:341
std::unique_ptr< ScUnoRefList > pUnoRefUndoList
Definition: document.hxx:397
std::shared_mutex mScLookupMutex
Definition: document.hxx:475
bool IsClipOrUndo() const
Definition: document.hxx:1591
void SetPreviewSelection(const ScMarkData &rSel)
Definition: documen2.cxx:1483
void SetError(SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError)
Definition: documen2.cxx:1130
SC_DLLPUBLIC void SetDocVisible(bool bSet)
Definition: documen2.cxx:261
bool bIsUndo
Definition: document.hxx:495
const OUString & GetCodeName() const
Definition: document.hxx:609
ScMarkData maPreviewSelection
Definition: document.hxx:433
void RemoveSortedRangeCache(ScSortedRangeCache &rCache)
Definition: documen2.cxx:1300
SC_DLLPUBLIC void TransferDrawPage(const ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos)
Definition: documen9.cxx:67
SC_DLLPUBLIC bool CopyTab(SCTAB nOldPos, SCTAB nNewPos, const ScMarkData *pOnlyMarked=nullptr)
Definition: documen2.cxx:806
void ImplDeleteOptions()
Definition: documen8.cxx:107
void SaveDdeLinks(SvStream &rStream) const
Definition: documen8.cxx:709
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1082
bool InterpretCellsIfNeeded(const ScRangeList &rRanges)
Definition: document.cxx:3956
SC_DLLPUBLIC ScNoteEditEngine & GetNoteEngine()
Definition: documen2.cxx:496
rtl_TextEncoding eSrcSet
Definition: document.hxx:455
bool TableExists(SCTAB nTab) const
Definition: document.cxx:2530
SC_DLLPUBLIC void ResetClip(ScDocument *pSourceDoc, const ScMarkData *pMarks)
Definition: documen2.cxx:525
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:603
std::unordered_map< ScColumn *, std::pair< SCROW, SCROW > > pDelayedStartListeningFormulaCells
Definition: document.hxx:529
VclPtr< VirtualDevice > mpVirtualDevice_100th_mm
Definition: document.hxx:373
void ApplyAsianEditSettings(ScEditEngineDefaulter &rEngine)
Definition: documen9.cxx:664
SfxItemSet * GetPreviewFont()
Definition: document.hxx:1389
std::unique_ptr< ScNoteEditEngine > mpNoteEngine
Definition: document.hxx:370
bool IsThreadedGroupCalcInProgress() const
Definition: document.hxx:630
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
std::unique_ptr< ScDBCollection > pDBCollection
Definition: document.hxx:382
std::unique_ptr< ScRefreshTimerControl > pRefreshTimerControl
Definition: document.hxx:400
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:237
void SetPreviewFont(std::unique_ptr< SfxItemSet > pFontSet)
Definition: documen2.cxx:1478
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:241
std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock
Definition: document.hxx:384
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
Definition: documen2.cxx:613
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:1391
sc::IconSetBitmapMap & GetIconSetBitmapMap()
Definition: documen2.cxx:1509
ScStyleSheet * GetPreviewCellStyle()
Definition: document.hxx:1393
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2495
void ImplCreateOptions()
Definition: documen8.cxx:101
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:996
std::unique_ptr< ScScriptTypeData > pScriptTypeData
Definition: document.hxx:399
void ForgetNoteCaptions(const ScRangeList &rRanges, bool bPreserveData)
Definition: document.cxx:6896
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:231
std::unique_ptr< ScDrawLayer > mpDrawLayer
Definition: document.hxx:374
SC_DLLPUBLIC bool GetDataStart(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow) const
Definition: documen2.cxx:681
SfxObjectShell * mpShell
Definition: document.hxx:371
bool IsPrintEntireSheet(SCTAB nTab) const
Returns true, if the specified sheet is always printed.
Definition: document.cxx:6399
void SetDirty(const ScRange &, bool bIncludeEmptyCells)
Definition: document.cxx:3900
void ClearLookupCaches()
Zap all caches.
Definition: documen2.cxx:1318
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:217
void SetNoListening(bool bVal)
Definition: document.hxx:2230
Idle aTrackIdle
Definition: document.hxx:441
ScRangePairListRef xColNameRanges
Definition: document.hxx:420
std::unique_ptr< ScRange > pDelayedFormulaGrouping
Definition: document.hxx:525
std::shared_ptr< sc::FormulaGroupContext > mpFormulaGroupCxt
Definition: document.hxx:363
bool MoveTab(SCTAB nOldPos, SCTAB nNewPos, ScProgress *pProgress=nullptr)
Definition: documen2.cxx:735
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1952
std::unique_ptr< ScRangeName > pRangeName
Definition: document.hxx:381
ScRefCellValue GetRefCellValue(const ScAddress &rPos)
Definition: documen2.cxx:587
SC_DLLPUBLIC void InitClipPtrs(ScDocument *pSourceDoc)
Definition: documen2.cxx:435
bool bIsVisible
Definition: document.hxx:497
void EndChangeTracking()
Definition: documen2.cxx:287
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:317
std::unique_ptr< ScChartListenerCollection > pChartListenerCollection
Definition: document.hxx:391
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:616
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)
const OUString & getString() const
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:252
std::unique_ptr< ScTable, o3tl::default_delete< ScTable > > ScTableUniquePtr
Definition: document.hxx:320
ScDocumentMode
Definition: document.hxx:255
@ SCDOCMODE_CLIP
Definition: document.hxx:257
@ SCDOCMODE_UNDO
Definition: document.hxx:258
@ SCDOCMODE_DOCUMENT
Definition: document.hxx:256
@ SCDOCMODE_FUNCTIONACCESS
Definition: document.hxx:259
@ CORE
Definition: document.hxx:317
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
sal_uInt16 nPos
#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.
Definition: broadcast.cxx:15
std::map< OUString, BitmapEx > IconSetBitmapMap
Definition: document.hxx:217
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:309
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:2763
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