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