LibreOffice Module sc (master) 1
document10.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
10#include <memory>
11#include <document.hxx>
12#include <clipcontext.hxx>
13#include <clipparam.hxx>
14#include <table.hxx>
15#include <tokenarray.hxx>
16#include <listenercontext.hxx>
18#include <poolhelp.hxx>
19#include <cellvalues.hxx>
20#include <docpool.hxx>
21#include <columniterator.hxx>
22
23#include <refupdatecontext.hxx>
24#include <sal/log.hxx>
25#include <editeng/colritem.hxx>
26#include <scitems.hxx>
27#include <datamapper.hxx>
28#include <docsh.hxx>
29
30// Add totally brand-new methods to this source file.
31
32bool ScDocument::IsMerged( const ScAddress& rPos ) const
33{
34 const ScTable* pTab = FetchTable(rPos.Tab());
35 if (!pTab)
36 return false;
37
38 return pTab->IsMerged(rPos.Col(), rPos.Row());
39}
40
42{
43 if (rRange.aStart.Tab() != rRange.aEnd.Tab())
44 // Currently we only support a single-sheet range.
46
47 const ScTable* pTab = FetchTable(rRange.aStart.Tab());
48 if (!pTab)
50
51 const ScAddress& s = rRange.aStart;
52 const ScAddress& e = rRange.aEnd;
53 return pTab->HasMultipleDataCells(s.Col(), s.Row(), e.Col(), e.Row());
54}
55
57 sc::CopyFromClipContext& rCxt, const ScMarkData& rMark, sc::ColumnSpanSet& rBroadcastSpans )
58{
59 SCTAB nClipTab = 0;
60 const TableContainer& rClipTabs = rCxt.getClipDoc()->maTabs;
61 SCTAB nClipTabCount = rClipTabs.size();
62
63 for (SCTAB nTab = rCxt.getTabStart(); nTab <= rCxt.getTabEnd(); ++nTab)
64 {
65 ScTable* pTab = FetchTable(nTab);
66 if (!pTab)
67 continue;
68
69 if (!rMark.GetTableSelect(nTab))
70 continue;
71
72 while (!rClipTabs[nClipTab])
73 nClipTab = (nClipTab+1) % nClipTabCount;
74
75 pTab->DeleteBeforeCopyFromClip(rCxt, *rClipTabs[nClipTab], rBroadcastSpans);
76
77 nClipTab = (nClipTab+1) % nClipTabCount;
78 }
79}
80
82 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
83{
84 ScDocument* pClipDoc = rCxt.getClipDoc();
85 if (pClipDoc->GetClipParam().mbCutMode)
86 // We don't handle cut and paste or moving of cells here.
87 return false;
88
89 ScRange aClipRange = pClipDoc->GetClipParam().getWholeRange();
90 if (aClipRange.aStart.Row() != aClipRange.aEnd.Row())
91 // The source is not really a single row. Bail out.
92 return false;
93
94 SCCOL nSrcColSize = aClipRange.aEnd.Col() - aClipRange.aStart.Col() + 1;
95 SCCOL nDestColSize = nCol2 - nCol1 + 1;
96 if (nDestColSize < nSrcColSize)
97 return false;
98
99 if (pClipDoc->maTabs.size() > 1)
100 // Copying from multiple source sheets is not handled here.
101 return false;
102
103 ScAddress aSrcPos = aClipRange.aStart;
104
105 for (SCCOL nCol = aClipRange.aStart.Col(); nCol <= aClipRange.aEnd.Col(); ++nCol)
106 {
107 ScAddress aTestPos = aSrcPos;
108 aTestPos.SetCol(nCol);
109 if (pClipDoc->IsMerged(aTestPos))
110 // We don't handle merged source cell for this.
111 return false;
112 }
113
114 ScTable* pSrcTab = pClipDoc->FetchTable(aSrcPos.Tab());
115 if (!pSrcTab)
116 return false;
117
118 rCxt.setSingleCellColumnSize(nSrcColSize);
119
120 for (SCCOL nColOffset = 0; nColOffset < nSrcColSize; ++nColOffset, aSrcPos.IncCol())
121 {
122 const ScPatternAttr* pAttr = pClipDoc->GetPattern(aSrcPos);
123 rCxt.setSingleCellPattern(nColOffset, pAttr);
124
126 rCxt.setSingleCellNote(nColOffset, pClipDoc->GetNote(aSrcPos));
127
129 rCxt.setSingleSparkline(nColOffset, pClipDoc->GetSparkline(aSrcPos));
130
131 ScColumn* pSrcCol = pSrcTab->FetchColumn(aSrcPos.Col());
132 assert(pSrcCol);
133 // Determine the script type of the copied single cell.
134 pSrcCol->UpdateScriptTypes(aSrcPos.Row(), aSrcPos.Row());
135 rCxt.setSingleCell(aSrcPos, *pSrcCol);
136 }
137
138 // All good. Proceed with the pasting.
139
140 SCTAB nTabEnd = rCxt.getTabEnd();
141 for (SCTAB i = rCxt.getTabStart(); i <= nTabEnd && i < static_cast<SCTAB>(maTabs.size()); ++i)
142 {
143 maTabs[i]->CopyOneCellFromClip(rCxt, nCol1, nRow1, nCol2, nRow2, aClipRange.aStart.Row(), pSrcTab);
144 }
145
146 sc::RefUpdateContext aRefCxt(*this);
147 aRefCxt.maRange = ScRange(nCol1, nRow1, rCxt.getTabStart(), nCol2, nRow2, nTabEnd);
148 aRefCxt.mnColDelta = nCol1 - aSrcPos.Col();
149 aRefCxt.mnRowDelta = nRow1 - aSrcPos.Row();
150 aRefCxt.mnTabDelta = rCxt.getTabStart() - aSrcPos.Tab();
151 // Only Copy&Paste, for Cut&Paste we already bailed out early.
152 aRefCxt.meMode = URM_COPY;
153 UpdateReference(aRefCxt, rCxt.getUndoDoc(), false);
154
155 return true;
156}
157
158void ScDocument::SetValues( const ScAddress& rPos, const std::vector<double>& rVals )
159{
160 ScTable* pTab = FetchTable(rPos.Tab());
161 if (!pTab)
162 return;
163
164 pTab->SetValues(rPos.Col(), rPos.Row(), rVals);
165}
166
167void ScDocument::TransferCellValuesTo( const ScAddress& rTopPos, size_t nLen, sc::CellValues& rDest )
168{
169 ScTable* pTab = FetchTable(rTopPos.Tab());
170 if (!pTab)
171 return;
172
173 pTab->TransferCellValuesTo(rTopPos.Col(), rTopPos.Row(), nLen, rDest);
174}
175
176void ScDocument::CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc )
177{
178 ScTable* pTab = FetchTable(rTopPos.Tab());
179 if (!pTab)
180 return;
181
182 pTab->CopyCellValuesFrom(rTopPos.Col(), rTopPos.Row(), rSrc);
183}
184
186{
187 std::set<Color> aDocColors;
188 ScDocumentPool *pPool = GetPool();
189 const sal_uInt16 pAttribs[] = {ATTR_BACKGROUND, ATTR_FONT_COLOR};
190 for (sal_uInt16 nAttrib : pAttribs)
191 {
192 for (const SfxPoolItem* pItem : pPool->GetItemSurrogates(nAttrib))
193 {
194 const SvxColorItem *pColorItem = static_cast<const SvxColorItem*>(pItem);
195 Color aColor( pColorItem->GetValue() );
196 if (COL_AUTO != aColor)
197 aDocColors.insert(aColor);
198 }
199 }
200 return aDocColors;
201}
202
204{
206 maCalcConfig = rConfig;
207}
208
210{
211 sc::EndListeningContext aCxt(*this);
212
213 for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
214 {
215 ScTable* pTab = FetchTable(nTab);
216 if (!pTab)
217 continue;
218
220 aCxt, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(),
221 pUndo);
222 }
223
225}
226
228{
229 const ScRange& rRange = rValues.getRange();
230 if (!rRange.IsValid())
231 return;
232
233 auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*this);
234 sc::StartListeningContext aStartCxt(*this, pPosSet);
235 sc::EndListeningContext aEndCxt(*this, pPosSet);
236
237 for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
238 {
239 ScTable* pTab = FetchTable(nTab);
240 if (!pTab)
241 continue;
242
243 pTab->SwapNonEmpty(rValues, aStartCxt, aEndCxt);
244 }
245
246 aEndCxt.purgeEmptyBroadcasters();
247}
248
249void ScDocument::PreprocessAllRangeNamesUpdate( const std::map<OUString, ScRangeName>& rRangeMap )
250{
251 // Update all existing names with new names.
252 // The prerequisites are that the name dialog preserves ScRangeData index
253 // for changes and does not reuse free index slots for new names.
254 // ScDocument::SetAllRangeNames() hereafter then will replace the
255 // ScRangeName containers of ScRangeData instances with empty
256 // ScRangeData::maNewName.
257 std::map<OUString, ScRangeName*> aRangeNameMap;
258 GetRangeNameMap( aRangeNameMap);
259 for (const auto& itTab : aRangeNameMap)
260 {
261 ScRangeName* pOldRangeNames = itTab.second;
262 if (!pOldRangeNames)
263 continue;
264
265 const auto& itNewTab( rRangeMap.find( itTab.first));
266 if (itNewTab == rRangeMap.end())
267 continue;
268
269 const ScRangeName& rNewRangeNames = itNewTab->second;
270
271 for (const auto& rEntry : *pOldRangeNames)
272 {
273 ScRangeData* pOldData = rEntry.second.get();
274 if (!pOldData)
275 continue;
276
277 const ScRangeData* pNewData = rNewRangeNames.findByIndex( pOldData->GetIndex());
278 if (pNewData)
279 pOldData->SetNewName( pNewData->GetName());
280 }
281 }
282
283 sc::EndListeningContext aEndListenCxt(*this);
284 sc::CompileFormulaContext aCompileCxt(*this);
285
286 for (const auto& rxTab : maTabs)
287 {
288 ScTable* p = rxTab.get();
289 p->PreprocessRangeNameUpdate(aEndListenCxt, aCompileCxt);
290 }
291}
292
294{
295 sc::EndListeningContext aEndListenCxt(*this);
296 sc::CompileFormulaContext aCompileCxt(*this);
297
298 for (const auto& rxTab : maTabs)
299 {
300 ScTable* p = rxTab.get();
301 p->PreprocessRangeNameUpdate(aEndListenCxt, aCompileCxt);
302 }
303}
304
306{
307 sc::EndListeningContext aEndListenCxt(*this);
308 sc::CompileFormulaContext aCompileCxt(*this);
309
310 for (const auto& rxTab : maTabs)
311 {
312 ScTable* p = rxTab.get();
313 p->PreprocessDBDataUpdate(aEndListenCxt, aCompileCxt);
314 }
315}
316
318{
319 sc::StartListeningContext aStartListenCxt(*this);
320 sc::CompileFormulaContext aCompileCxt(*this);
321 for (const auto& rxTab : maTabs)
322 {
323 ScTable* p = rxTab.get();
324 p->CompileHybridFormula(aStartListenCxt, aCompileCxt);
325 }
326}
327
329{
331 mxPoolHelper = pSrcDoc->mxPoolHelper;
333}
334
335void ScDocument::UpdateScriptTypes( const ScAddress& rPos, SCCOL nColSize, SCROW nRowSize )
336{
337 ScTable* pTab = FetchTable(rPos.Tab());
338 if (!pTab)
339 return;
340
341 pTab->UpdateScriptTypes(rPos.Col(), rPos.Row(), rPos.Col()+nColSize-1, rPos.Row()+nRowSize-1);
342}
343
344bool ScDocument::HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const
345{
346 const ScTable* pTab = FetchTable(nTab);
347 if (!pTab)
348 return false;
349
350 return pTab->HasUniformRowHeight(nRow1, nRow2);
351}
352
353void ScDocument::UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows )
354{
355 ScTable* pTab = FetchTable(nTab);
356 if (!pTab)
357 return;
358
359 pTab->UnshareFormulaCells(nCol, rRows);
360}
361
363{
364 ScTable* pTab = FetchTable(nTab);
365 if (!pTab)
366 return;
367
368 pTab->RegroupFormulaCells(nCol);
369}
370
372{
373 for( SCTAB tab = rRange.aStart.Tab(); tab <= rRange.aEnd.Tab(); ++tab )
374 for( SCCOL col = rRange.aStart.Col(); col <= rRange.aEnd.Col(); ++col )
375 RegroupFormulaCells( tab, col );
376}
377
379{
380 if( delay )
381 {
384 }
385 else
386 {
390 }
391}
392
394{
395 if( !pDelayedFormulaGrouping->Contains( cell->aPos ))
396 pDelayedFormulaGrouping->ExtendTo( cell->aPos );
397}
398
400{
401 if( delay )
402 {
404 pDelayedStartListeningFormulaCells[ column ] = std::pair<SCROW, SCROW>( -1, -1 );
405 }
406 else
407 {
408 auto it = pDelayedStartListeningFormulaCells.find( column );
410 {
411 if( it->second.first != -1 )
412 {
413 auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*this);
414 sc::StartListeningContext aStartCxt(*this, pPosSet);
415 sc::EndListeningContext aEndCxt(*this, pPosSet);
416 column->StartListeningFormulaCells(aStartCxt, aEndCxt, it->second.first, it->second.second);
417 }
419 }
420 }
421}
422
424{
426}
427
429{
430 auto it = pDelayedStartListeningFormulaCells.find( column );
432 return false; // not enabled
433 if( it->second.first == -1 && it->second.second == -1 ) // uninitialized
434 pDelayedStartListeningFormulaCells[ column ] = std::make_pair( row1, row2 );
435 else
436 {
437 if( row1 > it->second.second + 1 || row2 < it->second.first - 1 )
438 { // two non-adjacent ranges, just bail out
439 return false;
440 }
441 it->second.first = std::min( it->second.first, row1 );
442 it->second.second = std::max( it->second.second, row2 );
443 }
444 return true;
445}
446
448{
450 return;
453 {
454 for (auto& rxTab : maTabs)
455 if (rxTab)
456 rxTab->DeleteEmptyBroadcasters();
457 }
458}
459
460bool ScDocument::HasFormulaCell( const ScRange& rRange ) const
461{
462 if (!rRange.IsValid())
463 return false;
464
465 for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
466 {
467 const ScTable* pTab = FetchTable(nTab);
468 if (!pTab)
469 continue;
470
471 if (pTab->HasFormulaCell(rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row()))
472 return true;
473 }
474
475 return false;
476}
477
479 sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector<ScAddress>* pGroupPos )
480{
481 ScTable* pTab = FetchTable(rPos.Tab());
482 if (!pTab)
483 return;
484
485 pTab->EndListeningIntersectedGroup(rCxt, rPos.Col(), rPos.Row(), pGroupPos);
486}
487
489 sc::EndListeningContext& rCxt, const ScRange& rRange, std::vector<ScAddress>* pGroupPos )
490{
491 for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
492 {
493 ScTable* pTab = FetchTable(nTab);
494 if (!pTab)
495 continue;
496
498 rCxt, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(),
499 pGroupPos);
500 }
501}
502
503void ScDocument::EndListeningGroups( const std::vector<ScAddress>& rPosArray )
504{
505 sc::EndListeningContext aCxt(*this);
506 for (const ScAddress& rPos : rPosArray)
507 {
508 ScTable* pTab = FetchTable(rPos.Tab());
509 if (!pTab)
510 return;
511
512 pTab->EndListeningGroup(aCxt, rPos.Col(), rPos.Row());
513 }
514
516}
517
518void ScDocument::SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArray )
519{
520 for (const ScAddress& rPos : rPosArray)
521 {
522 ScTable* pTab = FetchTable(rPos.Tab());
523 if (!pTab)
524 return;
525
526 pTab->SetNeedsListeningGroup(rPos.Col(), rPos.Row());
527 }
528}
529
530namespace {
531
532class StartNeededListenersHandler
533{
534 std::shared_ptr<sc::StartListeningContext> mpCxt;
535public:
536 explicit StartNeededListenersHandler( ScDocument& rDoc ) : mpCxt(std::make_shared<sc::StartListeningContext>(rDoc)) {}
537 explicit StartNeededListenersHandler( ScDocument& rDoc, const std::shared_ptr<const sc::ColumnSet>& rpColSet ) :
538 mpCxt(std::make_shared<sc::StartListeningContext>(rDoc))
539 {
540 mpCxt->setColumnSet( rpColSet);
541 }
542
543 void operator() (const ScTableUniquePtr & p)
544 {
545 if (p)
546 p->StartListeners(*mpCxt, false);
547 }
548};
549
550}
551
553{
554 std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
555}
556
557void ScDocument::StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet )
558{
559 std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this, rpColSet));
560}
561
563{
564 if (IsClipOrUndo() || GetNoListening())
565 return;
566
567 auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*this);
568 sc::StartListeningContext aStartCxt(*this, pPosSet);
569 sc::EndListeningContext aEndCxt(*this, pPosSet);
570
571 for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
572 {
573 ScTable* pTab = FetchTable(nTab);
574 if (!pTab)
575 continue;
576
578 aStartCxt, aEndCxt,
579 rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row());
580 }
581}
582
584{
585 for (const auto& rxTab : maTabs)
586 {
587 ScTable* p = rxTab.get();
588 p->finalizeOutlineImport();
589 }
590}
591
593 SCTAB nTokenTab, const sal_uInt16 nTokenIndex,
594 SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement,
595 bool bSameDoc, int nRecursion) const
596{
597 if (nTokenTab < -1)
598 {
599 SAL_WARN("sc.core", "ScDocument::FindRangeNamesReferencingSheet - nTokenTab < -1 : " <<
600 nTokenTab << ", nTokenIndex " << nTokenIndex << " Fix the creator!");
601#if OSL_DEBUG_LEVEL > 0
602 const ScRangeData* pData = FindRangeNameBySheetAndIndex( nTokenTab, nTokenIndex);
603 SAL_WARN_IF( pData, "sc.core", "ScDocument::FindRangeNamesReferencingSheet - named expression is: " << pData->GetName());
604#endif
605 nTokenTab = -1;
606 }
607 SCTAB nRefTab = nGlobalRefTab;
608 if (nTokenTab == nOldTokenTab)
609 {
610 nTokenTab = nOldTokenTabReplacement;
611 nRefTab = nLocalRefTab;
612 }
613 else if (nTokenTab == nOldTokenTabReplacement)
614 {
615 nRefTab = nLocalRefTab;
616 }
617
618 if (rIndexes.isNameUpdated( nTokenTab, nTokenIndex))
619 return true;
620
621 ScRangeData* pData = FindRangeNameBySheetAndIndex( nTokenTab, nTokenIndex);
622 if (!pData)
623 return false;
624
625 ScTokenArray* pCode = pData->GetCode();
626 if (!pCode)
627 return false;
628
629 bool bRef = !bSameDoc; // include every name used when copying to other doc
630 if (nRecursion < 126) // whatever... 42*3
631 {
633 for (const formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
634 {
635 if (p->GetOpCode() == ocName)
636 {
637 bRef |= FindRangeNamesReferencingSheet( rIndexes, p->GetSheet(), p->GetIndex(),
638 nGlobalRefTab, nLocalRefTab, nOldTokenTab, nOldTokenTabReplacement, bSameDoc, nRecursion+1);
639 }
640 }
641 }
642
643 if (!bRef)
644 {
645 SCTAB nPosTab = pData->GetPos().Tab();
646 if (nPosTab == nOldTokenTab)
647 nPosTab = nOldTokenTabReplacement;
648 bRef = pCode->ReferencesSheet( nRefTab, nPosTab);
649 }
650 if (bRef)
651 rIndexes.setUpdatedName( nTokenTab, nTokenIndex);
652
653 return bRef;
654}
655
656namespace {
657
658enum MightReferenceSheet
659{
660 UNKNOWN,
661 NONE,
662 CODE,
663 NAME
664};
665
666MightReferenceSheet mightRangeNameReferenceSheet( ScRangeData* pData, SCTAB nRefTab)
667{
668 ScTokenArray* pCode = pData->GetCode();
669 if (!pCode)
671
673 for (const formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
674 {
675 if (p->GetOpCode() == ocName)
676 return MightReferenceSheet::NAME;
677 }
678
679 return pCode->ReferencesSheet( nRefTab, pData->GetPos().Tab()) ?
680 MightReferenceSheet::CODE : MightReferenceSheet::NONE;
681}
682
683ScRangeData* copyRangeName( const ScRangeData* pOldRangeData, ScDocument& rNewDoc, const ScDocument& rOldDoc,
684 const ScAddress& rNewPos, const ScAddress& rOldPos, bool bGlobalNamesToLocal,
685 SCTAB nOldSheet, const SCTAB nNewSheet, bool bSameDoc)
686{
687 ScAddress aRangePos( pOldRangeData->GetPos());
688 if (nNewSheet >= 0)
689 aRangePos.SetTab( nNewSheet);
690 ScRangeData* pRangeData = new ScRangeData(*pOldRangeData, &rNewDoc, &aRangePos);
691 pRangeData->SetIndex(0); // needed for insert to assign a new index
692 ScTokenArray* pRangeNameToken = pRangeData->GetCode();
693 if (bSameDoc && nNewSheet >= 0)
694 {
695 if (bGlobalNamesToLocal && nOldSheet < 0)
696 {
697 nOldSheet = rOldPos.Tab();
698 if (rNewPos.Tab() <= nOldSheet)
699 // Sheet was inserted before and references already updated.
700 ++nOldSheet;
701 }
702 pRangeNameToken->AdjustSheetLocalNameReferences( nOldSheet, nNewSheet);
703 }
704 if (!bSameDoc)
705 {
706 pRangeNameToken->ReadjustAbsolute3DReferences(rOldDoc, rNewDoc, pRangeData->GetPos(), true);
707 pRangeNameToken->AdjustAbsoluteRefs(rOldDoc, rOldPos, rNewPos, true);
708 }
709
710 bool bInserted;
711 if (nNewSheet < 0)
712 bInserted = rNewDoc.GetRangeName()->insert(pRangeData);
713 else
714 bInserted = rNewDoc.GetRangeName(nNewSheet)->insert(pRangeData);
715
716 return bInserted ? pRangeData : nullptr;
717}
718
719struct SheetIndex
720{
721 SCTAB mnSheet;
722 sal_uInt16 mnIndex;
723
724 SheetIndex( SCTAB nSheet, sal_uInt16 nIndex ) : mnSheet(nSheet < -1 ? -1 : nSheet), mnIndex(nIndex) {}
725 bool operator<( const SheetIndex& r ) const
726 {
727 // Ascending order sheet, index
728 if (mnSheet < r.mnSheet)
729 return true;
730 if (mnSheet == r.mnSheet)
731 return mnIndex < r.mnIndex;
732 return false;
733 }
734};
735typedef std::map< SheetIndex, SheetIndex > SheetIndexMap;
736
737ScRangeData* copyRangeNames( SheetIndexMap& rSheetIndexMap, std::vector<ScRangeData*>& rRangeDataVec,
738 const sc::UpdatedRangeNames& rReferencingNames, SCTAB nTab,
739 const ScRangeData* pOldRangeData, ScDocument& rNewDoc, const ScDocument& rOldDoc,
740 const ScAddress& rNewPos, const ScAddress& rOldPos, bool bGlobalNamesToLocal,
741 const SCTAB nOldSheet, const SCTAB nNewSheet, bool bSameDoc)
742{
743 ScRangeData* pRangeData = nullptr;
744 const ScRangeName* pOldRangeName = (nTab < 0 ? rOldDoc.GetRangeName() : rOldDoc.GetRangeName(nTab));
745 if (pOldRangeName)
746 {
747 const ScRangeName* pNewRangeName = (nNewSheet < 0 ? rNewDoc.GetRangeName() : rNewDoc.GetRangeName(nNewSheet));
748 sc::UpdatedRangeNames::NameIndicesType aSet( rReferencingNames.getUpdatedNames(nTab));
749 for (auto const & rIndex : aSet)
750 {
751 const ScRangeData* pCopyData = pOldRangeName->findByIndex(rIndex);
752 if (pCopyData)
753 {
754 // Match the original pOldRangeData to adapt the current
755 // token's values later. For that no check for an already
756 // copied name is needed as we only enter here if there was
757 // none.
758 if (pCopyData == pOldRangeData)
759 {
760 pRangeData = copyRangeName( pCopyData, rNewDoc, rOldDoc, rNewPos, rOldPos,
761 bGlobalNamesToLocal, nOldSheet, nNewSheet, bSameDoc);
762 if (pRangeData)
763 {
764 rRangeDataVec.push_back(pRangeData);
765 rSheetIndexMap.insert( std::make_pair( SheetIndex( nOldSheet, pCopyData->GetIndex()),
766 SheetIndex( nNewSheet, pRangeData->GetIndex())));
767 }
768 }
769 else
770 {
771 // First check if the name is already available as copy.
772 const ScRangeData* pFoundData = pNewRangeName->findByUpperName( pCopyData->GetUpperName());
773 if (pFoundData)
774 {
775 // Just add the resulting sheet/index mapping.
776 rSheetIndexMap.insert( std::make_pair( SheetIndex( nOldSheet, pCopyData->GetIndex()),
777 SheetIndex( nNewSheet, pFoundData->GetIndex())));
778 }
779 else
780 {
781 ScRangeData* pTmpData = copyRangeName( pCopyData, rNewDoc, rOldDoc, rNewPos, rOldPos,
782 bGlobalNamesToLocal, nOldSheet, nNewSheet, bSameDoc);
783 if (pTmpData)
784 {
785 rRangeDataVec.push_back(pTmpData);
786 rSheetIndexMap.insert( std::make_pair( SheetIndex( nOldSheet, pCopyData->GetIndex()),
787 SheetIndex( nNewSheet, pTmpData->GetIndex())));
788 }
789 }
790 }
791 }
792 }
793 }
794 return pRangeData;
795}
796
797} // namespace
798
799bool ScDocument::CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData,
800 ScDocument& rNewDoc, const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal,
801 const bool bUsedByFormula ) const
802{
803 ScDocument* pThis = const_cast<ScDocument*>(this);
804 const bool bSameDoc = (rNewDoc.GetPool() == pThis->GetPool());
805 if (bSameDoc && ((rSheet < 0 && !bGlobalNamesToLocal) || (rSheet >= 0
806 && (rSheet != rOldPos.Tab() || (IsClipboard() && pThis->IsCutMode())))))
807 // Same doc and global name, if not copied to local name, or
808 // sheet-local name on other sheet stays the same. Sheet-local on
809 // same sheet also in a clipboard cut&paste / move operation.
810 return false;
811
812 // Ensure we don't fiddle with the references until exit.
813 const SCTAB nOldSheet = rSheet;
814 const sal_uInt16 nOldIndex = rIndex;
815
816 SAL_WARN_IF( !bSameDoc && nOldSheet >= 0 && nOldSheet != rOldPos.Tab(),
817 "sc.core", "adjustCopyRangeName - sheet-local name was on other sheet in other document");
818 /* TODO: can we do something about that? e.g. loop over sheets? */
819
820 OUString aRangeName;
821 ScRangeData* pOldRangeData = nullptr;
822
823 // XXX bGlobalNamesToLocal is also a synonym for copied sheet.
824 bool bInsertingBefore = (bGlobalNamesToLocal && bSameDoc && rNewPos.Tab() <= rOldPos.Tab());
825
826 // The Tab where an old local name is to be found or that a global name
827 // references. May differ below from nOldSheet if a sheet was inserted
828 // before the old position. Global names and local names other than on the
829 // old sheet or new sheet are already updated, local names on the old sheet
830 // or inserted sheet will be updated later. Confusing stuff. Watch out.
831 SCTAB nOldTab = (nOldSheet < 0 ? rOldPos.Tab() : nOldSheet);
832 if (bInsertingBefore)
833 // Sheet was already inserted before old position.
834 ++nOldTab;
835
836 // Search the name of the RangeName.
837 if (nOldSheet >= 0)
838 {
839 const ScRangeName* pNames = GetRangeName(nOldTab);
840 pOldRangeData = pNames ? pNames->findByIndex(nOldIndex) : nullptr;
841 if (!pOldRangeData)
842 return false; // might be an error in the formula array
843 aRangeName = pOldRangeData->GetUpperName();
844 }
845 else
846 {
847 pOldRangeData = GetRangeName()->findByIndex(nOldIndex);
848 if (!pOldRangeData)
849 return false; // might be an error in the formula array
850 aRangeName = pOldRangeData->GetUpperName();
851 }
852
853 // Find corresponding range name in new document.
854 // First search for local range name then global range names.
855 SCTAB nNewSheet = rNewPos.Tab();
856 ScRangeName* pNewNames = rNewDoc.GetRangeName(nNewSheet);
857 // Search local range names.
858 if (pNewNames)
859 {
860 rpRangeData = pNewNames->findByUpperName(aRangeName);
861 }
862 // Search global range names.
863 if (!rpRangeData && !bGlobalNamesToLocal)
864 {
865 nNewSheet = -1;
866 pNewNames = rNewDoc.GetRangeName();
867 if (pNewNames)
868 rpRangeData = pNewNames->findByUpperName(aRangeName);
869 }
870 // If no range name was found copy it.
871 if (!rpRangeData)
872 {
873 // Do not copy global name if it doesn't reference sheet or is not used
874 // by a formula copied to another document.
875 bool bEarlyBailOut = (nOldSheet < 0 && (bSameDoc || !bUsedByFormula));
876 MightReferenceSheet eMightReference = mightRangeNameReferenceSheet( pOldRangeData, nOldTab);
877 if (bEarlyBailOut && eMightReference == MightReferenceSheet::NONE)
878 return false;
879
880 if (eMightReference == MightReferenceSheet::NAME)
881 {
882 // Name these to clarify what is passed where.
883 const SCTAB nGlobalRefTab = nOldTab;
884 const SCTAB nLocalRefTab = (bInsertingBefore ? nOldTab-1 : nOldTab);
885 const SCTAB nOldTokenTab = (nOldSheet < 0 ? (bInsertingBefore ? nOldTab-1 : nOldTab) : nOldSheet);
886 const SCTAB nOldTokenTabReplacement = nOldTab;
887 sc::UpdatedRangeNames aReferencingNames;
888 FindRangeNamesReferencingSheet( aReferencingNames, nOldSheet, nOldIndex,
889 nGlobalRefTab, nLocalRefTab, nOldTokenTab, nOldTokenTabReplacement, bSameDoc, 0);
890 if (bEarlyBailOut && aReferencingNames.isEmpty(-1) && aReferencingNames.isEmpty(nOldTokenTabReplacement))
891 return false;
892
893 SheetIndexMap aSheetIndexMap;
894 std::vector<ScRangeData*> aRangeDataVec;
895 if (!aReferencingNames.isEmpty(nOldTokenTabReplacement))
896 {
897 const SCTAB nTmpOldSheet = (nOldSheet < 0 ? nOldTab : nOldSheet);
898 nNewSheet = rNewPos.Tab();
899 rpRangeData = copyRangeNames( aSheetIndexMap, aRangeDataVec, aReferencingNames, nOldTab,
900 pOldRangeData, rNewDoc, *this, rNewPos, rOldPos,
901 bGlobalNamesToLocal, nTmpOldSheet, nNewSheet, bSameDoc);
902 }
903 if ((bGlobalNamesToLocal || !bSameDoc) && !aReferencingNames.isEmpty(-1))
904 {
905 const SCTAB nTmpOldSheet = -1;
906 const SCTAB nTmpNewSheet = (bGlobalNamesToLocal ? rNewPos.Tab() : -1);
907 ScRangeData* pTmpData = copyRangeNames( aSheetIndexMap, aRangeDataVec, aReferencingNames, -1,
908 pOldRangeData, rNewDoc, *this, rNewPos, rOldPos,
909 bGlobalNamesToLocal, nTmpOldSheet, nTmpNewSheet, bSameDoc);
910 if (!rpRangeData)
911 {
912 rpRangeData = pTmpData;
913 nNewSheet = nTmpNewSheet;
914 }
915 }
916
917 // Adjust copied nested names to new sheet/index.
918 for (auto & iRD : aRangeDataVec)
919 {
920 ScTokenArray* pCode = iRD->GetCode();
921 if (pCode)
922 {
924 for (formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
925 {
926 if (p->GetOpCode() == ocName)
927 {
928 auto it = aSheetIndexMap.find( SheetIndex( p->GetSheet(), p->GetIndex()));
929 if (it != aSheetIndexMap.end())
930 {
931 p->SetSheet( it->second.mnSheet);
932 p->SetIndex( it->second.mnIndex);
933 }
934 else if (!bSameDoc)
935 {
936 SAL_WARN("sc.core","adjustCopyRangeName - mapping to new name in other doc missing");
937 p->SetIndex(0); // #NAME? error instead of arbitrary name.
938 }
939 }
940 }
941 }
942 }
943 }
944 else
945 {
946 nNewSheet = ((nOldSheet < 0 && !bGlobalNamesToLocal) ? -1 : rNewPos.Tab());
947 rpRangeData = copyRangeName( pOldRangeData, rNewDoc, *this, rNewPos, rOldPos, bGlobalNamesToLocal,
948 nOldSheet, nNewSheet, bSameDoc);
949 }
950
951 if (rpRangeData && !rNewDoc.IsClipOrUndo())
952 {
953 ScDocShell* pDocSh = static_cast<ScDocShell*>(rNewDoc.GetDocumentShell());
954 if (pDocSh)
956 }
957 }
958
959 rSheet = nNewSheet;
960 rIndex = rpRangeData ? rpRangeData->GetIndex() : 0; // 0 means not inserted
961 return true;
962}
963
965 sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd ) const
966{
967 const ScTable* pTab = FetchTable(nTab);
968 if (!pTab)
969 return false;
970
971 return pTab->IsEditActionAllowed(eAction, nStart, nEnd);
972}
973
975 sc::ColRowEditAction eAction, const ScMarkData& rMark, SCCOLROW nStart, SCCOLROW nEnd ) const
976{
977 return std::all_of(rMark.begin(), rMark.end(),
978 [this, &eAction, &nStart, &nEnd](const SCTAB& rTab) { return IsEditActionAllowed(eAction, rTab, nStart, nEnd); });
979}
980
981std::optional<sc::ColumnIterator> ScDocument::GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const
982{
983 const ScTable* pTab = FetchTable(nTab);
984 if (!pTab)
985 return {};
986
987 return pTab->GetColumnIterator(nCol, nRow1, nRow2);
988}
989
991{
992 ScTable* pTab = FetchTable(nTab);
993 if (!pTab)
994 return;
995
996 pTab->CreateColumnIfNotExists(nCol);
997}
998
999bool ScDocument::EnsureFormulaCellResults( const ScRange& rRange, bool bSkipRunning )
1000{
1001 bool bAnyDirty = false;
1002 for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
1003 {
1004 ScTable* pTab = FetchTable(nTab);
1005 if (!pTab)
1006 continue;
1007
1008 bool bRet = pTab->EnsureFormulaCellResults(
1009 rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), bSkipRunning);
1010 bAnyDirty = bAnyDirty || bRet;
1011 }
1012
1013 return bAnyDirty;
1014}
1015
1017{
1018 if (!mpDataMapper)
1019 mpDataMapper.reset(new sc::ExternalDataMapper(*this));
1020
1021 return *mpDataMapper;
1022}
1023
1025{
1026 const ScTable* pTab = FetchTable(nTab);
1027 if (!pTab)
1028 return;
1029
1030 pTab->StoreToCache(rStrm);
1031}
1032
1034{
1035 ScTable* pTab = FetchTable(nTab);
1036 if (!pTab)
1037 return;
1038
1039 pTab->RestoreFromCache(rStrm);
1040}
1041
1042OString ScDocument::dumpSheetGeomData(SCTAB nTab, bool bColumns, SheetGeomType eGeomType)
1043{
1044 ScTable* pTab = FetchTable(nTab);
1045 if (!pTab)
1046 return "";
1047
1048 return pTab->dumpSheetGeomData(bColumns, eGeomType);
1049}
1050
1052{
1053 const ScTable* pTab = FetchTable(nTab);
1054 if (!pTab)
1055 return -1;
1056
1057 return pTab->GetLOKFreezeCol();
1058}
1060{
1061 const ScTable* pTab = FetchTable(nTab);
1062 if (!pTab)
1063 return -1;
1064
1065 return pTab->GetLOKFreezeRow();
1066}
1067
1069{
1070 ScTable* pTab = FetchTable(nTab);
1071 if (!pTab)
1072 return false;
1073
1074 return pTab->SetLOKFreezeCol(nFreezeCol);
1075}
1076
1078{
1079 ScTable* pTab = FetchTable(nTab);
1080 if (!pTab)
1081 return false;
1082
1083 return pTab->SetLOKFreezeRow(nFreezeRow);
1084}
1085
1087{
1088 const ScTable* pTab = FetchTable(nTab);
1089 if (!pTab)
1090 return std::set<SCCOL>{};
1091
1092 return pTab->QueryColumnsWithFormulaCells();
1093}
1094
1096{
1097 const ScTable* pTab = FetchTable(nTab);
1098 if (!pTab)
1099 return;
1100
1101 pTab->CheckIntegrity();
1102}
1103
1104/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
int mnIndex
NAME
SCTAB Tab() const
Definition: address.hxx:283
void SetCol(SCCOL nColP)
Definition: address.hxx:291
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:316
SCROW Row() const
Definition: address.hxx:274
@ INITIALIZE_INVALID
Definition: address.hxx:221
SCCOL Col() const
Definition: address.hxx:279
void UpdateScriptTypes(SCROW nRow1, SCROW nRow2)
Definition: column4.cxx:1193
void StartListeningFormulaCells(sc::StartListeningContext &rStartCxt, sc::EndListeningContext &rEndCxt, SCROW nRow1, SCROW nRow2)
Definition: column4.cxx:1593
void SetAreasChangedNeedBroadcast()
Definition: docsh.hxx:389
void StartAllListeners()
Definition: documen7.cxx:588
std::unique_ptr< sc::ExternalDataMapper > mpDataMapper
Definition: document.hxx:402
std::shared_ptr< svl::SharedStringPool > mpCellStringPool
Definition: document.hxx:359
SC_DLLPUBLIC std::shared_ptr< sc::Sparkline > GetSparkline(ScAddress const &rPosition)
Returns sparkline at the address if it exists.
Definition: document.cxx:6624
bool bDelayedDeletingBroadcasters
Definition: document.hxx:530
SC_DLLPUBLIC void GetRangeNameMap(std::map< OUString, ScRangeName * > &rRangeName)
Definition: documen3.cxx:152
std::set< SCCOL > QueryColumnsWithFormulaCells(SCTAB nTab) const
sc::MultiDataCellState HasMultipleDataCells(const ScRange &rRange) const
Check if the specified range contains either: 1) one non-empty cell, 2) more than one non-empty cells...
Definition: document10.cxx:41
void EnableDelayStartListeningFormulaCells(ScColumn *column, bool delay)
If set, ScColumn::StartListeningFormulaCells() calls may be delayed using CanDelayStartListeningFormu...
Definition: document10.cxx:399
void SetValues(const ScAddress &rPos, const std::vector< double > &rVals)
Definition: document10.cxx:158
bool FindRangeNamesReferencingSheet(sc::UpdatedRangeNames &rIndexes, SCTAB nTokenTab, const sal_uInt16 nTokenIndex, SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement, bool bSameDoc, int nRecursion) const
Recursively find all named expressions that directly or indirectly (nested) reference a given sheet,...
Definition: document10.cxx:592
SC_DLLPUBLIC ScRangeName * GetRangeName() const
Definition: documen3.cxx:182
ScTable * FetchTable(SCTAB nTab)
Definition: document.cxx:2544
bool SetLOKFreezeCol(SCCOL nFreezeCol, SCTAB nTab)
ScClipParam & GetClipParam()
Definition: document.cxx:2600
SC_DLLPUBLIC void CompileHybridFormula()
Call this immediately after updating named ranges.
Definition: document10.cxx:317
bool IsEditActionAllowed(sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd) const
Definition: document10.cxx:964
void EnableDelayDeletingBroadcasters(bool set)
If set, cells will not delete their empty broadcasters, avoiding possible extensive mdds vector chang...
Definition: document10.cxx:447
void finalizeOutlineImport()
Definition: document10.cxx:583
void SetNeedsListeningGroups(const std::vector< ScAddress > &rPosArray)
Definition: document10.cxx:518
std::vector< ScTableUniquePtr > TableContainer
Definition: document.hxx:346
void SharePooledResources(const ScDocument *pSrcDoc)
Definition: document10.cxx:328
bool IsClipboard() const
Definition: document.hxx:1592
bool HasUniformRowHeight(SCTAB nTab, SCROW nRow1, SCROW nRow2) const
Definition: document10.cxx:344
rtl::Reference< ScPoolHelper > mxPoolHelper
Definition: document.hxx:357
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6169
bool IsCutMode()
Definition: document.cxx:2060
ScRangeData * FindRangeNameBySheetAndIndex(SCTAB nTab, sal_uInt16 nIndex) const
Find a named expression / range name in either global or a local scope.
Definition: documen3.cxx:275
void UpdateReference(sc::RefUpdateContext &rCxt, ScDocument *pUndoDoc=nullptr, bool bIncludeDraw=true, bool bUpdateNoteCaptionPos=true)
Definition: documen3.cxx:1014
SC_DLLPUBLIC ScPostIt * GetNote(const ScAddress &rPos)
Definition: document.cxx:6729
void CreateColumnIfNotExists(SCTAB nTab, SCCOL nCol)
Definition: document10.cxx:990
std::set< Color > GetDocColors()
Definition: document10.cxx:185
bool HasFormulaCell(const ScRange &rRange) const
Check if there is at least one formula cell in specified range.
Definition: document10.cxx:460
SC_DLLPUBLIC void PreprocessDBDataUpdate()
Definition: document10.cxx:305
void DelayFormulaGrouping(bool delay)
If set, joining cells into shared formula groups will be delayed until reset again (RegroupFormulaCel...
Definition: document10.cxx:378
SC_DLLPUBLIC void PreprocessRangeNameUpdate()
Definition: document10.cxx:293
SC_DLLPUBLIC bool EnsureFormulaCellResults(const ScRange &rRange, bool bSkipRunning=false)
Make sure all of the formula cells in the specified range have been fully calculated.
Definition: document10.cxx:999
void EndListeningGroups(const std::vector< ScAddress > &rPosArray)
Definition: document10.cxx:503
void UnshareFormulaCells(SCTAB nTab, SCCOL nCol, std::vector< SCROW > &rRows)
Make specified formula cells non-grouped.
Definition: document10.cxx:353
void AddDelayedFormulaGroupingCell(const ScFormulaCell *cell)
To be used only by SharedFormulaUtil::joinFormulaCells().
Definition: document10.cxx:393
bool SetLOKFreezeRow(SCROW nFreezeRow, SCTAB nTab)
bool GetNoListening() const
Definition: document.hxx:2225
TableContainer maTabs
Definition: document.hxx:377
SCCOL GetLOKFreezeCol(SCTAB nTab) const
void EndListeningIntersectedGroups(sc::EndListeningContext &rCxt, const ScRange &rRange, std::vector< ScAddress > *pGroupPos)
Definition: document10.cxx:488
SC_DLLPUBLIC sc::ExternalDataMapper & GetExternalDataMapper()
SC_DLLPUBLIC bool CopyOneCellFromClip(sc::CopyFromClipContext &rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: document10.cxx:81
OString dumpSheetGeomData(SCTAB nTab, bool bColumns, SheetGeomType eGeomType)
Serializes the specified sheet's geometry data.
SC_DLLPUBLIC void SetCalcConfig(const ScCalcConfig &rConfig)
Definition: document10.cxx:203
void UpdateScriptTypes(const ScAddress &rPos, SCCOL nColSize, SCROW nRowSize)
Definition: document10.cxx:335
void RegroupFormulaCells(SCTAB nTab, SCCOL nCol)
Definition: document10.cxx:362
bool IsClipOrUndo() const
Definition: document.hxx:1590
SCROW GetLOKFreezeRow(SCTAB nTab) const
void ConvertFormulaToValue(const ScRange &rRange, sc::TableValues *pUndo)
Definition: document10.cxx:209
void CheckIntegrity(SCTAB nTab) const
Check the integrity of the internal table state.
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1081
void DeleteBeforeCopyFromClip(sc::CopyFromClipContext &rCxt, const ScMarkData &rMark, sc::ColumnSpanSet &rBroadcastSpans)
Definition: document10.cxx:56
SC_DLLPUBLIC void RestoreTabFromCache(SCTAB nTab, SvStream &rStream)
std::unordered_map< ScColumn *, std::pair< SCROW, SCROW > > pDelayedStartListeningFormulaCells
Definition: document.hxx:528
SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate(const std::map< OUString, ScRangeName > &rRangeMap)
Call this immediately before updating all named ranges.
Definition: document10.cxx:249
SC_DLLPUBLIC void StoreTabToCache(SCTAB nTab, SvStream &rStrm) const
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:174
void CopyCellValuesFrom(const ScAddress &rTopPos, const sc::CellValues &rSrc)
Definition: document10.cxx:176
void SwapNonEmpty(sc::TableValues &rValues)
Definition: document10.cxx:227
bool IsMerged(const ScAddress &rPos) const
Definition: document10.cxx:32
bool CanDelayStartListeningFormulaCells(ScColumn *column, SCROW row1, SCROW row2)
If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed lat...
Definition: document10.cxx:428
std::optional< sc::ColumnIterator > GetColumnIterator(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2) const
Definition: document10.cxx:981
bool CopyAdjustRangeName(SCTAB &rSheet, sal_uInt16 &rIndex, ScRangeData *&rpRangeData, ScDocument &rNewDoc, const ScAddress &rNewPos, const ScAddress &rOldPos, const bool bGlobalNamesToLocal, const bool bUsedByFormula) const
If necessary (name references sheet rOldPos.Tab()) copy and adjust named expression/range from sheet-...
Definition: document10.cxx:799
ScCalcConfig maCalcConfig
Definition: document.hxx:365
void TransferCellValuesTo(const ScAddress &rTopPos, size_t nLen, sc::CellValues &rDest)
Transfer a series of contiguous cell values from specified position to the passed container.
Definition: document10.cxx:167
std::unique_ptr< ScRange > pDelayedFormulaGrouping
Definition: document.hxx:524
void StartNeededListeners()
Definition: document10.cxx:552
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4812
void EndListeningIntersectedGroup(sc::EndListeningContext &rCxt, const ScAddress &rPos, std::vector< ScAddress > *pGroupPos)
Definition: document10.cxx:478
bool IsEnabledDelayStartListeningFormulaCells(ScColumn *column) const
Definition: document10.cxx:423
ScAddress aPos
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
const_iterator end() const
Definition: markdata.hxx:164
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:169
const_iterator begin() const
Definition: markdata.hxx:163
ScTokenArray * GetCode()
Definition: rangenam.hxx:119
void GetName(OUString &rName) const
Definition: rangenam.hxx:110
void SetIndex(sal_uInt16 nInd)
Definition: rangenam.hxx:115
void SetNewName(const OUString &rNewName)
Does not change the name, but sets maNewName for formula update after dialog.
Definition: rangenam.hxx:118
const ScAddress & GetPos() const
Definition: rangenam.hxx:113
sal_uInt16 GetIndex() const
Definition: rangenam.hxx:116
const OUString & GetUpperName() const
Definition: rangenam.hxx:112
SC_DLLPUBLIC ScRangeData * findByIndex(sal_uInt16 i) const
Definition: rangenam.cxx:716
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:704
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
Definition: rangenam.cxx:802
ScAddress aEnd
Definition: address.hxx:498
bool IsValid() const
Definition: address.hxx:544
ScAddress aStart
Definition: address.hxx:497
SCCOL GetLOKFreezeCol() const
Definition: table7.cxx:589
ScColumn * FetchColumn(SCCOL nCol)
Definition: table2.cxx:1235
bool HasFormulaCell(const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2) const
Definition: table7.cxx:294
void EndListeningGroup(sc::EndListeningContext &rCxt, const SCCOL nCol, SCROW nRow)
Definition: table7.cxx:328
bool IsEditActionAllowed(sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd) const
Definition: table7.cxx:344
void UpdateScriptTypes(const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2)
Definition: table7.cxx:246
ScColumn & CreateColumnIfNotExists(const SCCOL nScCol)
Definition: table.hxx:289
void CheckIntegrity() const
Definition: table7.cxx:646
std::optional< sc::ColumnIterator > GetColumnIterator(SCCOL nCol, SCROW nRow1, SCROW nRow2) const
Definition: table7.cxx:425
bool HasUniformRowHeight(SCROW nRow1, SCROW nRow2) const
Definition: table7.cxx:257
SCROW GetLOKFreezeRow() const
Definition: table7.cxx:594
sc::MultiDataCellState HasMultipleDataCells(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Definition: table7.cxx:35
void SetNeedsListeningGroup(SCCOL nCol, SCROW nRow)
Definition: table7.cxx:336
void SetValues(const SCCOL nCol, const SCROW nRow, const std::vector< double > &rVals)
Definition: table7.cxx:181
void DeleteBeforeCopyFromClip(sc::CopyFromClipContext &rCxt, const ScTable &rClipTab, sc::ColumnSpanSet &rBroadcastSpans)
Definition: table7.cxx:98
OString dumpSheetGeomData(bool bColumns, SheetGeomType eGeomType)
Serializes the sheet's geometry data.
Definition: table7.cxx:485
void UnshareFormulaCells(SCCOL nCol, std::vector< SCROW > &rRows)
Definition: table7.cxx:278
void EndListeningIntersectedGroups(sc::EndListeningContext &rCxt, const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, std::vector< ScAddress > *pGroupPos)
Definition: table7.cxx:317
void RestoreFromCache(SvStream &rStrm)
Definition: table7.cxx:475
void ConvertFormulaToValue(sc::EndListeningContext &rCxt, const SCCOL nCol1, const SCROW nRow1, const SCCOL nCol2, const SCROW nRow2, sc::TableValues *pUndo)
Definition: table7.cxx:205
bool EnsureFormulaCellResults(const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, bool bSkipRunning=false)
Definition: table7.cxx:433
void SwapNonEmpty(sc::TableValues &rValues, sc::StartListeningContext &rStartCxt, sc::EndListeningContext &rEndCxt)
Definition: table7.cxx:216
std::set< SCCOL > QueryColumnsWithFormulaCells() const
Definition: table7.cxx:633
void TransferCellValuesTo(const SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues &rDest)
Definition: table7.cxx:189
void CopyCellValuesFrom(const SCCOL nCol, SCROW nRow, const sc::CellValues &rSrc)
Definition: table7.cxx:197
void EndListeningIntersectedGroup(sc::EndListeningContext &rCxt, SCCOL nCol, SCROW nRow, std::vector< ScAddress > *pGroupPos)
Definition: table7.cxx:308
void RegroupFormulaCells(SCCOL nCol)
Definition: table7.cxx:286
void StoreToCache(SvStream &rStrm) const
Definition: table7.cxx:459
bool SetLOKFreezeCol(SCCOL nFreezeCol)
Definition: table7.cxx:599
void StartListeningFormulaCells(sc::StartListeningContext &rStartCxt, sc::EndListeningContext &rEndCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: table2.cxx:1298
bool SetLOKFreezeRow(SCROW nFreezeRow)
Definition: table7.cxx:616
bool IsMerged(SCCOL nCol, SCROW nRow) const
Definition: table7.cxx:27
bool ReferencesSheet(SCTAB nTab, SCTAB nPosTab) const
Returns true if the sheet nTab is referenced in code.
Definition: token.cxx:2693
void AdjustSheetLocalNameReferences(SCTAB nOldTab, SCTAB nNewTab)
When copying a sheet-local named expression, move sheet references that point to the originating shee...
Definition: token.cxx:2645
void AdjustAbsoluteRefs(const ScDocument &rOldDoc, const ScAddress &rOldPos, const ScAddress &rNewPos, bool bCheckCopyArea)
Make all absolute references pointing to the copied range if the range is copied too.
Definition: token.cxx:2597
void ReadjustAbsolute3DReferences(const ScDocument &rOldDoc, ScDocument &rNewDoc, const ScAddress &rPos, bool bRangeName=false)
Make all absolute references external references pointing to the old document.
Definition: token.cxx:2545
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
const Color & GetValue() const
FormulaToken ** GetCode() const
Think of this as a mini-ScColumn like storage that only stores cell values in a column.
Definition: cellvalues.hxx:41
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
void setSingleCellPattern(size_t nColOffset, const ScPatternAttr *pAttr)
void setSingleCellNote(size_t nColOffset, const ScPostIt *pNote)
void setSingleCellColumnSize(size_t nSize)
Set the column size of a "single cell" row, which is used when copying a single row of cells in a cli...
void setSingleSparkline(size_t nColOffset, std::shared_ptr< sc::Sparkline > const &pSparkline)
InsertDeleteFlags getInsertFlag() const
void setSingleCell(const ScAddress &rSrcPos, const ScColumn &rSrcCol)
SCTAB getTabStart() const
Definition: clipcontext.cxx:63
ScDocument * getUndoDoc()
Definition: clipcontext.cxx:91
SCTAB getTabEnd() const
Definition: clipcontext.cxx:68
ScDocument * getClipDoc()
Definition: clipcontext.cxx:96
Stores cell values for multiple tables.
Definition: cellvalues.hxx:86
const ScRange & getRange() const
Definition: cellvalues.cxx:317
Keep track of all named expressions that have been updated during reference update.
std::unordered_set< sal_uInt16 > NameIndicesType
NameIndicesType getUpdatedNames(SCTAB nTab) const
bool isNameUpdated(SCTAB nTab, sal_uInt16 nIndex) const
void setUpdatedName(SCTAB nTab, sal_uInt16 nIndex)
bool isEmpty(SCTAB nTab) const
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
std::unique_ptr< ScTable, o3tl::default_delete< ScTable > > ScTableUniquePtr
Definition: document.hxx:319
SheetGeomType
Represents the type of sheet geometry data.
Definition: document.hxx:276
@ CORE
Definition: document.hxx:316
bool operator<(const ScDPCollection::DBType &left, const ScDPCollection::DBType &right)
Definition: dpobject.cxx:3941
UNKNOWN
@ URM_COPY
Definition: global.hxx:302
@ SPARKLINES
Sheet / outlining (grouping) information.
@ NOTE
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
@ ADDNOTES
Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
sal_Int32 nIndex
void * p
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
void set(css::uno::UnoInterfaceReference const &value)
int i
void SvStream & rStrm
std::shared_ptr< T > make_shared(Args &&... args)
CAUTION! The following defines must be in the same namespace as the respective type.
ColRowEditAction
Definition: global.hxx:426
ocName
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
Configuration options for formula interpreter.
Definition: calcconfig.hxx:44
bool mbCutMode
Definition: clipparam.hxx:36
ScRange getWholeRange() const
Return a single range that encompasses all individual ranges.
Definition: clipparam.cxx:109
A pretty assertion that checks that the relevant bits in the @nFlags are not set on the document at e...
Definition: document.hxx:2758
Context for reference update during shifting, moving or copying of cell ranges.
SCROW mnRowDelta
Amount and direction of movement in the row direction.
UpdateRefMode meMode
update mode - insert/delete, copy, or move.
SCCOL mnColDelta
Amount and direction of movement in the column direction.
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_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17