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