LibreOffice Module sc (master) 1
documen3.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
21#include <com/sun/star/sheet/TableValidationVisibility.hpp>
22#include <scitems.hxx>
23#include <editeng/langitem.hxx>
24#include <svl/srchitem.hxx>
25#include <sfx2/linkmgr.hxx>
26#include <sfx2/bindings.hxx>
27#include <sfx2/objsh.hxx>
28#include <sfx2/viewsh.hxx>
29#include <vcl/svapp.hxx>
30#include <osl/thread.hxx>
31#include <osl/diagnose.h>
32#include <tools/duration.hxx>
33#include <document.hxx>
34#include <attrib.hxx>
35#include <table.hxx>
36#include <rangenam.hxx>
37#include <dbdata.hxx>
38#include <docpool.hxx>
39#include <poolhelp.hxx>
40#include <rangelst.hxx>
41#include <chartlock.hxx>
42#include <refupdat.hxx>
43#include <docoptio.hxx>
44#include <scmod.hxx>
45#include <clipoptions.hxx>
46#include <viewopti.hxx>
47#include <scextopt.hxx>
48#include <tablink.hxx>
49#include <externalrefmgr.hxx>
50#include <markdata.hxx>
51#include <validat.hxx>
52#include <dociter.hxx>
53#include <detdata.hxx>
54#include <inputopt.hxx>
55#include <chartlis.hxx>
56#include <sc.hrc>
57#include <hints.hxx>
58#include <dpobject.hxx>
59#include <drwlayer.hxx>
60#include <unoreflist.hxx>
61#include <listenercalls.hxx>
62#include <tabprotection.hxx>
63#include <formulaparserpool.hxx>
64#include <clipparam.hxx>
65#include <sheetevents.hxx>
66#include <queryentry.hxx>
67#include <formulacell.hxx>
68#include <refupdatecontext.hxx>
69#include <scopetools.hxx>
70#include <filterentries.hxx>
71#include <queryparam.hxx>
72
73#include <globalnames.hxx>
74#include <LibreOfficeKit/LibreOfficeKitEnums.h>
75#include <comphelper/lok.hxx>
76#include <config_fuzzers.h>
77#include <memory>
78
79using namespace com::sun::star;
80
81namespace {
82
83void sortAndRemoveDuplicates(std::vector<ScTypedStrData>& rStrings, bool bCaseSens)
84{
85 if (bCaseSens)
86 {
87 std::stable_sort(rStrings.begin(), rStrings.end(), ScTypedStrData::LessCaseSensitive());
88 std::vector<ScTypedStrData>::iterator it =
89 std::unique(rStrings.begin(), rStrings.end(), ScTypedStrData::EqualCaseSensitive());
90 rStrings.erase(it, rStrings.end());
91 }
92 else
93 {
94 std::stable_sort(rStrings.begin(), rStrings.end(), ScTypedStrData::LessCaseInsensitive());
95 std::vector<ScTypedStrData>::iterator it =
96 std::unique(rStrings.begin(), rStrings.end(), ScTypedStrData::EqualCaseInsensitive());
97 rStrings.erase(it, rStrings.end());
98 }
99 if (std::any_of(rStrings.begin(), rStrings.end(),
100 [](ScTypedStrData& rString) { return rString.IsHiddenByFilter(); })) {
101 std::stable_sort(rStrings.begin(), rStrings.end(), ScTypedStrData::LessHiddenRows());
102 }
103}
104
105}
106
108{
110 for (SCTAB i = 0; i < GetTableCount(); ++i)
111 {
112 if (!maTabs[i])
113 // no more tables to iterate through.
114 break;
115
116 const ScRangeName* p = maTabs[i]->mpRangeName.get();
117 if (!p || p->empty())
118 // ignore empty ones.
119 continue;
120
121 aNames.emplace(i, p);
122 }
123 rNames.swap(aNames);
124}
125
126void ScDocument::SetAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap)
127{
128 for (const auto& [rName, rRangeName] : rRangeMap)
129 {
130 if (rName == STR_GLOBAL_RANGE_NAME)
131 {
132 pRangeName.reset();
133 if (!rRangeName.empty())
134 pRangeName.reset( new ScRangeName( rRangeName ) );
135 }
136 else
137 {
138 SCTAB nTab;
139 bool bFound = GetTable(rName, nTab);
140 assert(bFound); (void)bFound; // fouled up?
141 if (rRangeName.empty())
142 SetRangeName( nTab, nullptr );
143 else
144 SetRangeName( nTab, std::unique_ptr<ScRangeName>(new ScRangeName( rRangeName )) );
145 }
146 }
147}
148
149void ScDocument::GetRangeNameMap(std::map<OUString, ScRangeName*>& aRangeNameMap)
150{
151 for (SCTAB i = 0; i < GetTableCount(); ++i)
152 {
153 if (!maTabs[i])
154 continue;
155 ScRangeName* p = maTabs[i]->GetRangeName();
156 if (!p )
157 {
158 p = new ScRangeName();
159 SetRangeName(i, std::unique_ptr<ScRangeName>(p));
160 }
161 OUString aTableName = maTabs[i]->GetName();
162 aRangeNameMap.insert(std::pair<OUString, ScRangeName*>(aTableName,p));
163 }
164 if (!pRangeName)
165 {
166 pRangeName.reset(new ScRangeName());
167 }
168 aRangeNameMap.insert(std::pair<OUString, ScRangeName*>(STR_GLOBAL_RANGE_NAME, pRangeName.get()));
169}
170
172{
173 if (const ScTable* pTable = FetchTable(nTab))
174 return pTable->GetRangeName();
175 return nullptr;
176}
177
179{
180 if (!pRangeName)
181 pRangeName.reset(new ScRangeName);
182 return pRangeName.get();
183}
184
185void ScDocument::SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew)
186{
187 if (ScTable* pTable = FetchTable(nTab))
188 pTable->SetRangeName(std::move(pNew));
189}
190
191void ScDocument::SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName )
192{
193 pRangeName = std::move(pNewRangeName);
194}
195
197{
198 ScRangeName* pRangeNames;
199 ScRange aNameRange;
200
201 if (eScope == RangeNameScope::GLOBAL)
202 pRangeNames= GetRangeName();
203 else
204 pRangeNames= GetRangeName(rAddress.Tab());
205
206 for (const auto& rEntry : *pRangeNames)
207 {
208 if (rEntry.second->IsValidReference(aNameRange))
209 {
210 if (aNameRange.Contains(rAddress))
211 return true;
212 }
213 }
214
215 return false;
216}
217
218bool ScDocument::InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr )
219{
220 ScRangeName* pGlobalNames = GetRangeName();
221 if (!pGlobalNames)
222 return false;
223
224 ScRangeData* pName = new ScRangeData(*this, rName, rExpr, rPos, ScRangeData::Type::Name, GetGrammar());
225 return pGlobalNames->insert(pName);
226}
227
228bool ScDocument::InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr )
229{
230 ScRangeName* pLocalNames = GetRangeName(nTab);
231 if (!pLocalNames)
232 return false;
233
234 ScRangeData* pName = new ScRangeData(*this, rName, rExpr, rPos, ScRangeData::Type::Name, GetGrammar());
235 return pLocalNames->insert(pName);
236}
237
238const ScRangeData* ScDocument::GetRangeAtBlock( const ScRange& rBlock, OUString& rName, bool* pSheetLocal ) const
239{
240 const ScRangeData* pData = nullptr;
241 if (rBlock.aStart.Tab() == rBlock.aEnd.Tab())
242 {
243 const ScRangeName* pLocalNames = GetRangeName(rBlock.aStart.Tab());
244 if (pLocalNames)
245 {
246 pData = pLocalNames->findByRange( rBlock );
247 if (pData)
248 {
249 rName = pData->GetName();
250 if (pSheetLocal)
251 *pSheetLocal = true;
252 return pData;
253 }
254 }
255 }
256 if ( pRangeName )
257 {
258 pData = pRangeName->findByRange( rBlock );
259 if (pData)
260 {
261 rName = pData->GetName();
262 if (pSheetLocal)
263 *pSheetLocal = false;
264 }
265 }
266 return pData;
267}
268
270{
271 const ScRangeName* pRN = (nTab < 0 ? GetRangeName() : GetRangeName(nTab));
272 return (pRN ? pRN->findByIndex( nIndex) : nullptr);
273}
274
275void ScDocument::SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection, bool bRemoveAutoFilter )
276{
277 if (pDBCollection && bRemoveAutoFilter)
278 {
279 // remove auto filter attribute if new db data don't contain auto filter flag
280 // start position is also compared, so bRemoveAutoFilter must not be set from ref-undo!
281
282 ScDBCollection::NamedDBs& rNamedDBs = pDBCollection->getNamedDBs();
283 for (const auto& rxNamedDB : rNamedDBs)
284 {
285 const ScDBData& rOldData = *rxNamedDB;
286 if (!rOldData.HasAutoFilter())
287 continue;
288
289 ScRange aOldRange;
290 rOldData.GetArea(aOldRange);
291
292 bool bFound = false;
293 if (pNewDBCollection)
294 {
295 ScDBData* pNewData = pNewDBCollection->getNamedDBs().findByUpperName(rOldData.GetUpperName());
296 if (pNewData)
297 {
298 if (pNewData->HasAutoFilter())
299 {
300 ScRange aNewRange;
301 pNewData->GetArea(aNewRange);
302 if (aOldRange.aStart == aNewRange.aStart)
303 bFound = true;
304 }
305 }
306 }
307
308 if (!bFound)
309 {
310 aOldRange.aEnd.SetRow(aOldRange.aStart.Row());
311 RemoveFlagsTab( aOldRange.aStart.Col(), aOldRange.aStart.Row(),
312 aOldRange.aEnd.Col(), aOldRange.aEnd.Row(),
313 aOldRange.aStart.Tab(), ScMF::Auto );
314 RepaintRange( aOldRange );
315 }
316 }
317 }
318
319 pDBCollection = std::move(pNewDBCollection);
320}
321
322const ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
323{
324 if (pDBCollection)
325 return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ePortion);
326 else
327 return nullptr;
328}
329
331{
332 if (pDBCollection)
333 return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ePortion);
334 else
335 return nullptr;
336}
337
338const ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
339{
340 if (pDBCollection)
341 return pDBCollection->GetDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2);
342 else
343 return nullptr;
344}
345
346ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
347{
348 if (pDBCollection)
349 return pDBCollection->GetDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2);
350 else
351 return nullptr;
352}
353
355{
356 if (pDBCollection)
357 pDBCollection->RefreshDirtyTableColumnNames();
358}
359
361{
362 return pDPCollection && pDPCollection->GetCount();
363}
364
366{
367 if (!pDPCollection)
368 pDPCollection.reset( new ScDPCollection(*this) );
369 return pDPCollection.get();
370}
371
373{
374 return pDPCollection.get();
375}
376
378{
379 if (!pDPCollection)
380 return nullptr;
381
382 sal_uInt16 nCount = pDPCollection->GetCount();
383 ScAddress aPos( nCol, nRow, nTab );
384 for (sal_uInt16 i=0; i<nCount; i++)
385 if ( (*pDPCollection)[i].GetOutRange().Contains( aPos ) )
386 return &(*pDPCollection)[i];
387
388 return nullptr;
389}
390
392{
393 if (!pDPCollection)
394 return nullptr;
395
396 /* Walk the collection in reverse order to get something of an
397 * approximation of MS Excels 'most recent' effect. */
398 sal_uInt16 i = pDPCollection->GetCount();
399 while ( i-- > 0 )
400 if ( (*pDPCollection)[i].GetOutRange().Contains( rBlock ) )
401 return &(*pDPCollection)[i];
402
403 return nullptr;
404}
405
407{
409 apTemporaryChartLock->StopLocking();
410}
411
413 std::unique_ptr<ScChartListenerCollection> pNewChartListenerCollection,
414 bool bSetChartRangeLists )
415{
416 std::unique_ptr<ScChartListenerCollection> pOld = std::move(pChartListenerCollection);
417 pChartListenerCollection = std::move(pNewChartListenerCollection);
419 {
420 if ( pOld )
421 pChartListenerCollection->SetDiffDirty( *pOld, bSetChartRangeLists );
422 pChartListenerCollection->StartAllListeners();
423 }
424}
425
426void ScDocument::SetScenario( SCTAB nTab, bool bFlag )
427{
428 if (ScTable* pTable = FetchTable(nTab))
429 pTable->SetScenario(bFlag);
430}
431
433{
434 const ScTable* pTable = FetchTable(nTab);
435 return pTable && pTable->IsScenario();
436}
437
438void ScDocument::SetScenarioData( SCTAB nTab, const OUString& rComment,
439 const Color& rColor, ScScenarioFlags nFlags )
440{
441 if (ScTable* pTable = FetchTable(nTab); pTable && pTable->IsScenario())
442 {
443 pTable->SetScenarioComment( rComment );
444 pTable->SetScenarioColor( rColor );
445 pTable->SetScenarioFlags( nFlags );
446 }
447}
448
450{
451 if (const ScTable* pTable = FetchTable(nTab))
452 return pTable->GetTabBgColor();
453 return COL_AUTO;
454}
455
456void ScDocument::SetTabBgColor( SCTAB nTab, const Color& rColor )
457{
458 if (ScTable* pTable = FetchTable(nTab))
459 pTable->SetTabBgColor(rColor);
460}
461
463{
464 if (const ScTable* pTable = FetchTable(nTab))
465 return pTable->GetTabBgColor() == COL_AUTO;
466 return true;
467}
468
469void ScDocument::GetScenarioData( SCTAB nTab, OUString& rComment,
470 Color& rColor, ScScenarioFlags& rFlags ) const
471{
472 if (const ScTable* pTable = FetchTable(nTab); pTable && pTable->IsScenario())
473 {
474 pTable->GetScenarioComment( rComment );
475 rColor = pTable->GetScenarioColor();
476 rFlags = pTable->GetScenarioFlags();
477 }
478}
479
481{
482 if (const ScTable* pTable = FetchTable(nTab); pTable && pTable->IsScenario())
483 rFlags = pTable->GetScenarioFlags();
484}
485
486bool ScDocument::IsLinked( SCTAB nTab ) const
487{
488 const ScTable* pTable = FetchTable(nTab);
489 return pTable && pTable->IsLinked();
490}
491
493{
495}
496
498{
499 eGrammar = eGram;
500}
501
503{
504 if (const ScTable* pTable = FetchTable(nTab))
505 return pTable->GetLinkMode();
506 return ScLinkMode::NONE;
507}
508
509OUString ScDocument::GetLinkDoc( SCTAB nTab ) const
510{
511 if (const ScTable* pTable = FetchTable(nTab))
512 return pTable->GetLinkDoc();
513 return OUString();
514}
515
516OUString ScDocument::GetLinkFlt( SCTAB nTab ) const
517{
518 if (const ScTable* pTable = FetchTable(nTab))
519 return pTable->GetLinkFlt();
520 return OUString();
521}
522
523OUString ScDocument::GetLinkOpt( SCTAB nTab ) const
524{
525 if (const ScTable* pTable = FetchTable(nTab))
526 return pTable->GetLinkOpt();
527 return OUString();
528}
529
530OUString ScDocument::GetLinkTab( SCTAB nTab ) const
531{
532 if (const ScTable* pTable = FetchTable(nTab))
533 return pTable->GetLinkTab();
534 return OUString();
535}
536
538{
539 if (const ScTable* pTable = FetchTable(nTab))
540 return pTable->GetLinkRefreshDelay();
541 return 0;
542}
543
544void ScDocument::SetLink( SCTAB nTab, ScLinkMode nMode, const OUString& rDoc,
545 const OUString& rFilter, const OUString& rOptions,
546 const OUString& rTabName, sal_uLong nRefreshDelay )
547{
548 if (ScTable* pTable = FetchTable(nTab))
549 pTable->SetLink(nMode, rDoc, rFilter, rOptions, rTabName, nRefreshDelay);
550}
551
552bool ScDocument::HasLink( std::u16string_view rDoc,
553 std::u16string_view rFilter, std::u16string_view rOptions ) const
554{
556 for (SCTAB i=0; i<nCount; i++)
557 if (maTabs[i]->IsLinked()
558 && maTabs[i]->GetLinkDoc() == rDoc
559 && maTabs[i]->GetLinkFlt() == rFilter
560 && maTabs[i]->GetLinkOpt() == rOptions)
561 return true;
562
563 return false;
564}
565
566bool ScDocument::LinkExternalTab( SCTAB& rTab, const OUString& aDocTab,
567 const OUString& aFileName, const OUString& aTabName )
568{
569 if ( IsClipboard() )
570 {
571 OSL_FAIL( "LinkExternalTab in Clipboard" );
572 return false;
573 }
574 rTab = 0;
575#if ENABLE_FUZZERS
576 (void)aDocTab;
577 (void)aFileName;
578 (void)aTabName;
579 return false;
580#else
581 OUString aFilterName; // Is filled by the Loader
582 OUString aOptions; // Filter options
583 sal_uInt32 nLinkCnt = pExtDocOptions ? pExtDocOptions->GetDocSettings().mnLinkCnt : 0;
584 ScDocumentLoader aLoader( aFileName, aFilterName, aOptions, nLinkCnt + 1 );
585 if ( aLoader.IsError() )
586 return false;
587 ScDocument* pSrcDoc = aLoader.GetDocument();
588
589 // Copy table
590 SCTAB nSrcTab;
591 if ( pSrcDoc->GetTable( aTabName, nSrcTab ) )
592 {
593 if ( !InsertTab( SC_TAB_APPEND, aDocTab, true ) )
594 {
595 OSL_FAIL("can't insert external document table");
596 return false;
597 }
598 rTab = GetTableCount() - 1;
599 // Don't insert anew, just the results
600 TransferTab( *pSrcDoc, nSrcTab, rTab, false, true );
601 }
602 else
603 return false;
604
605 sal_uLong nRefreshDelay = 0;
606
607 bool bWasThere = HasLink( aFileName, aFilterName, aOptions );
608 SetLink( rTab, ScLinkMode::VALUE, aFileName, aFilterName, aOptions, aTabName, nRefreshDelay );
609 if ( !bWasThere ) // Add link only once per source document
610 {
611 ScTableLink* pLink = new ScTableLink( mpShell, aFileName, aFilterName, aOptions, nRefreshDelay );
612 pLink->SetInCreate( true );
613 OUString aFilName = aFilterName;
615 pLink->Update();
616 pLink->SetInCreate( false );
617 SfxBindings* pBindings = GetViewBindings();
618 if (pBindings)
619 pBindings->Invalidate( SID_LINKS );
620 }
621 return true;
622#endif
623}
624
626{
627 ScDocument* pThis = const_cast<ScDocument*>(this);
628 if (!pExternalRefMgr)
629 pThis->pExternalRefMgr.reset( new ScExternalRefManager(*pThis));
630
631 return pExternalRefMgr.get();
632}
633
635{
636 return pExternalRefMgr && pExternalRefMgr->isInReferenceMarking();
637}
638
640{
641 if (!pExternalRefMgr)
642 return;
643 if (!pExternalRefMgr->hasExternalData())
644 return;
645 // Charts.
646 pExternalRefMgr->markUsedByLinkListeners();
647 // Formula cells.
648 pExternalRefMgr->markUsedExternalRefCells();
649
650 /* NOTE: Conditional formats and validation objects are marked when
651 * collecting them during export. */
652}
653
655{
657 mxFormulaParserPool.reset( new ScFormulaParserPool( *this ) );
658 return *mxFormulaParserPool;
659}
660
662{
663 if (const ScTable* pTable = FetchTable(nTab))
664 return pTable->GetSheetEvents();
665 return nullptr;
666}
667
668void ScDocument::SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew )
669{
670 if (ScTable* pTable = FetchTable(nTab))
671 pTable->SetSheetEvents( std::move(pNew) );
672}
673
674bool ScDocument::HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents ) const
675{
676 if (const ScTable* pTable = FetchTable(nTab))
677 {
678 // check if any event handler script has been configured
679 const ScSheetEvents* pEvents = pTable->GetSheetEvents();
680 if ( pEvents && pEvents->GetScript( nEvent ) )
681 return true;
682 // check if VBA event handlers exist
683 if (bWithVbaEvents && mxVbaEvents.is()) try
684 {
685 uno::Sequence< uno::Any > aArgs{ uno::Any(nTab) };
686 if (mxVbaEvents->hasVbaEventHandler( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ) ||
687 mxVbaEvents->hasVbaEventHandler( ScSheetEvents::GetVbaDocumentEventId( nEvent ), uno::Sequence< uno::Any >() ))
688 return true;
689 }
690 catch( uno::Exception& )
691 {
692 }
693 }
694 return false;
695}
696
697bool ScDocument::HasAnySheetEventScript( ScSheetEventId nEvent, bool bWithVbaEvents ) const
698{
699 SCTAB nSize = GetTableCount();
700 for (SCTAB nTab = 0; nTab < nSize; nTab++)
701 if (HasSheetEventScript( nTab, nEvent, bWithVbaEvents ))
702 return true;
703 return false;
704}
705
707{
708 SCTAB nSize = GetTableCount();
709 for (SCTAB nTab = 0; nTab < nSize; nTab++)
710 if (maTabs[nTab] && maTabs[nTab]->GetCalcNotification())
711 return true;
712 return false;
713}
714
716{
717 if (const ScTable* pTable = FetchTable(nTab))
718 return pTable->GetCalcNotification();
719 return false;
720}
721
723{
724 // set only if not set before
725 if (ScTable* pTable = FetchTable(nTab) ; pTable && !pTable->GetCalcNotification())
726 pTable->SetCalcNotification(true);
727}
728
730{
731 SCTAB nSize = GetTableCount();
732 for (SCTAB nTab = 0; nTab < nSize; nTab++)
733 if (maTabs[nTab] && maTabs[nTab]->GetCalcNotification())
734 maTabs[nTab]->SetCalcNotification(false);
735}
736
738{
739 ScOutlineTable* pVal = nullptr;
740
741 if (ScTable* pTable = FetchTable(nTab))
742 {
743 pVal = pTable->GetOutlineTable();
744 if (!pVal && bCreate)
745 {
746 pTable->StartOutlineTable();
747 pVal = pTable->GetOutlineTable();
748 }
749 }
750
751 return pVal;
752}
753
754bool ScDocument::SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline )
755{
756 ScTable* pTable = FetchTable(nTab);
757 return pTable && pTable->SetOutlineTable(pNewOutline);
758}
759
760void ScDocument::DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
761 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab )
762{
763 if (ScTable* pTable = FetchTable(nTab))
764 pTable->DoAutoOutline( nStartCol, nStartRow, nEndCol, nEndRow );
765}
766
768{
769 ScTable* pTable = FetchTable(nTab);
770 return pTable && pTable->TestRemoveSubTotals(rParam);
771}
772
774{
775 if (ScTable* pTable = FetchTable(nTab))
776 pTable->RemoveSubTotals( rParam );
777}
778
780{
781 ScTable* pTable = FetchTable(nTab);
782 return pTable && pTable->DoSubTotals(rParam);
783}
784
786{
787 ScCellIterator aIter(*this, rRange);
788 for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
789 {
790 if (aIter.getType() != CELLTYPE_FORMULA)
791 continue;
792
793 if (aIter.getFormulaCell()->IsSubTotal())
794 return true;
795 }
796 return false; // none found
797}
798
804{
806 for (SCTAB nTab=0; nTab<nCount; nTab++)
807 if (maTabs[nTab] && pPosDoc->maTabs[nTab] && pDestDoc->maTabs[nTab])
808 maTabs[nTab]->CopyUpdated( pPosDoc->maTabs[nTab].get(), pDestDoc->maTabs[nTab].get() );
809}
810
811void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario )
812{
813 if (!HasTable(nSrcTab) || !HasTable(nDestTab))
814 return;
815
816 // Set flags correctly for active scenarios
817 // and write current values back to recently active scenarios
818 ScRangeList aRanges = *maTabs[nSrcTab]->GetScenarioRanges();
819
820 // nDestTab is the target table
821 for ( SCTAB nTab = nDestTab+1;
822 nTab < GetTableCount() && maTabs[nTab] && maTabs[nTab]->IsScenario();
823 nTab++ )
824 {
825 if ( maTabs[nTab]->IsActiveScenario() ) // Even if it's the same scenario
826 {
827 bool bTouched = false;
828 for ( size_t nR=0, nRangeCount = aRanges.size(); nR < nRangeCount && !bTouched; nR++ )
829 {
830 const ScRange& rRange = aRanges[ nR ];
831 if ( maTabs[nTab]->HasScenarioRange( rRange ) )
832 bTouched = true;
833 }
834 if (bTouched)
835 {
836 maTabs[nTab]->SetActiveScenario(false);
838 maTabs[nTab]->CopyScenarioFrom( maTabs[nDestTab].get() );
839 }
840 }
841 }
842
843 maTabs[nSrcTab]->SetActiveScenario(true); // This is where it's from ...
844 if (!bNewScenario) // Copy data from the selected scenario
845 {
846 sc::AutoCalcSwitch aACSwitch(*this, false);
847 maTabs[nSrcTab]->CopyScenarioTo( maTabs[nDestTab].get() );
848
851 }
852}
853
854void ScDocument::MarkScenario( SCTAB nSrcTab, SCTAB nDestTab, ScMarkData& rDestMark,
855 bool bResetMark, ScScenarioFlags nNeededBits ) const
856{
857 if (bResetMark)
858 rDestMark.ResetMark();
859
860 if (const ScTable* pTable = FetchTable(nSrcTab))
861 pTable->MarkScenarioIn(rDestMark, nNeededBits);
862
863 rDestMark.SetAreaTab( nDestTab);
864}
865
866bool ScDocument::HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const
867{
868 const ScTable* pTable = FetchTable(nTab);
869 return pTable && pTable->HasScenarioRange(rRange);
870}
871
873{
874 if (const ScTable* pTable = FetchTable(nTab))
875 return pTable->GetScenarioRanges();
876
877 return nullptr;
878}
879
881{
882 const ScTable* pTable = FetchTable(nTab);
883 return pTable && pTable->IsActiveScenario();
884}
885
886void ScDocument::SetActiveScenario( SCTAB nTab, bool bActive )
887{
888 if (ScTable* pTable = FetchTable(nTab))
889 pTable->SetActiveScenario( bActive );
890}
891
892bool ScDocument::TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const
893{
894 if (HasTable(nSrcTab) && HasTable(nDestTab))
895 return maTabs[nSrcTab]->TestCopyScenarioTo(maTabs[nDestTab].get());
896
897 OSL_FAIL("wrong table at TestCopyScenario");
898 return false;
899}
900
902{
903 if (!pUnoBroadcaster)
904 pUnoBroadcaster.reset( new SfxBroadcaster );
905
907}
908
910{
911 if (pUnoBroadcaster)
912 {
913 rObject.EndListening( *pUnoBroadcaster );
914
915 if ( bInUnoBroadcast )
916 {
917 // Broadcasts from ScDocument::BroadcastUno are the only way that
918 // uno object methods are called without holding a reference.
919 //
920 // If RemoveUnoObject is called from an object dtor in the finalizer thread
921 // while the main thread is calling BroadcastUno, the dtor thread must wait
922 // (or the object's Notify might try to access a deleted object).
923 // The SolarMutex can't be locked here because if a component is called from
924 // a VCL event, the main thread has the SolarMutex locked all the time.
925 //
926 // This check is done after calling EndListening, so a later BroadcastUno call
927 // won't touch this object.
928
930 if (g.isAcquired())
931 {
932 // BroadcastUno is always called with the SolarMutex locked, so if it
933 // can be acquired, this is within the same thread (should not happen)
934 OSL_FAIL( "RemoveUnoObject called from BroadcastUno" );
935 }
936 else
937 {
938 // Let the thread that called BroadcastUno continue
939 while ( bInUnoBroadcast )
940 {
941 osl::Thread::yield();
942 }
943 }
944 }
945 }
946 else
947 {
948 OSL_FAIL("No Uno broadcaster");
949 }
950}
951
953{
954 if (!pUnoBroadcaster)
955 return;
956
957 bInUnoBroadcast = true;
958 pUnoBroadcaster->Broadcast( rHint );
959 bInUnoBroadcast = false;
960
961 // During Broadcast notification, Uno objects can add to pUnoListenerCalls.
962 // The listener calls must be processed after completing the broadcast,
963 // because they can add or remove objects from pUnoBroadcaster.
964
965 if ( pUnoListenerCalls &&
966 rHint.GetId() == SfxHintId::DataChanged &&
968 {
969 // Listener calls may lead to BroadcastUno calls again. The listener calls
970 // are not nested, instead the calls are collected in the list, and the
971 // outermost call executes them all.
972
973 ScChartLockGuard aChartLockGuard(this);
974 bInUnoListenerCall = true;
975 pUnoListenerCalls->ExecuteAndClear();
976 bInUnoListenerCall = false;
977 }
978}
979
980void ScDocument::AddUnoListenerCall( const uno::Reference<util::XModifyListener>& rListener,
981 const lang::EventObject& rEvent )
982{
983 OSL_ENSURE( bInUnoBroadcast, "AddUnoListenerCall is supposed to be called from BroadcastUno only" );
984
985 if ( !pUnoListenerCalls )
987 pUnoListenerCalls->Add( rListener, rEvent );
988}
989
991{
992 OSL_ENSURE( !pUnoRefUndoList, "BeginUnoRefUndo twice" );
993 pUnoRefUndoList.reset( new ScUnoRefList );
994}
995
996std::unique_ptr<ScUnoRefList> ScDocument::EndUnoRefUndo()
997{
998 return std::move(pUnoRefUndoList);
999 // Must be deleted by caller!
1000}
1001
1002void ScDocument::AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges )
1003{
1004 if ( pUnoRefUndoList )
1005 pUnoRefUndoList->Add( nId, rOldRanges );
1006}
1007
1009 sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, bool bIncludeDraw, bool bUpdateNoteCaptionPos )
1010{
1011 if (!ValidRange(rCxt.maRange) && !(rCxt.meMode == URM_INSDEL &&
1012 ((rCxt.mnColDelta < 0 && // convention from ScDocument::DeleteCol()
1013 rCxt.maRange.aStart.Col() == GetMaxColCount() && rCxt.maRange.aEnd.Col() == GetMaxColCount()) ||
1014 (rCxt.mnRowDelta < 0 && // convention from ScDocument::DeleteRow()
1015 rCxt.maRange.aStart.Row() == GetMaxRowCount() && rCxt.maRange.aEnd.Row() == GetMaxRowCount()))))
1016 return;
1017
1018 std::unique_ptr<sc::ExpandRefsSwitch> pExpandRefsSwitch;
1019 if (rCxt.isInserted())
1020 pExpandRefsSwitch.reset(new sc::ExpandRefsSwitch(*this, SC_MOD()->GetInputOptions().GetExpandRefs()));
1021
1022 size_t nFirstTab, nLastTab;
1023 if (rCxt.meMode == URM_COPY)
1024 {
1025 nFirstTab = rCxt.maRange.aStart.Tab();
1026 nLastTab = rCxt.maRange.aEnd.Tab();
1027 }
1028 else
1029 {
1030 // TODO: Have these methods use the context object directly.
1031 ScRange aRange = rCxt.maRange;
1032 UpdateRefMode eUpdateRefMode = rCxt.meMode;
1033 SCCOL nDx = rCxt.mnColDelta;
1034 SCROW nDy = rCxt.mnRowDelta;
1035 SCTAB nDz = rCxt.mnTabDelta;
1036 SCCOL nCol1 = rCxt.maRange.aStart.Col(), nCol2 = rCxt.maRange.aEnd.Col();
1037 SCROW nRow1 = rCxt.maRange.aStart.Row(), nRow2 = rCxt.maRange.aEnd.Row();
1038 SCTAB nTab1 = rCxt.maRange.aStart.Tab(), nTab2 = rCxt.maRange.aEnd.Tab();
1039
1040 xColNameRanges->UpdateReference( eUpdateRefMode, this, aRange, nDx, nDy, nDz );
1041 xRowNameRanges->UpdateReference( eUpdateRefMode, this, aRange, nDx, nDy, nDz );
1042 pDBCollection->UpdateReference( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz );
1043 if (pRangeName)
1044 pRangeName->UpdateReference(rCxt);
1045 if ( pDPCollection )
1046 pDPCollection->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz );
1047 UpdateChartRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz );
1048 UpdateRefAreaLinks( eUpdateRefMode, aRange, nDx, nDy, nDz );
1049 if ( pValidationList )
1050 {
1052 pValidationList->UpdateReference(rCxt);
1053 }
1054 if ( pDetOpList )
1055 pDetOpList->UpdateReference( this, eUpdateRefMode, aRange, nDx, nDy, nDz );
1056 if ( pUnoBroadcaster )
1057 pUnoBroadcaster->Broadcast( ScUpdateRefHint(
1058 eUpdateRefMode, aRange, nDx, nDy, nDz ) );
1059
1060 nFirstTab = 0;
1061 nLastTab = maTabs.size()-1;
1062 }
1063
1064 for (size_t i = nFirstTab, n = maTabs.size() ; i <= nLastTab && i < n; ++i)
1065 {
1066 if (!maTabs[i])
1067 continue;
1068
1069 maTabs[i]->UpdateReference(rCxt, pUndoDoc, bIncludeDraw, bUpdateNoteCaptionPos);
1070 }
1071
1072 if ( bIsEmbedded )
1073 {
1074 SCCOL theCol1;
1075 SCROW theRow1;
1076 SCTAB theTab1;
1077 SCCOL theCol2;
1078 SCROW theRow2;
1079 SCTAB theTab2;
1080 theCol1 = aEmbedRange.aStart.Col();
1081 theRow1 = aEmbedRange.aStart.Row();
1082 theTab1 = aEmbedRange.aStart.Tab();
1083 theCol2 = aEmbedRange.aEnd.Col();
1084 theRow2 = aEmbedRange.aEnd.Row();
1085 theTab2 = aEmbedRange.aEnd.Tab();
1086
1087 // TODO: Have ScRefUpdate::Update() use the context object directly.
1088 UpdateRefMode eUpdateRefMode = rCxt.meMode;
1089 SCCOL nDx = rCxt.mnColDelta;
1090 SCROW nDy = rCxt.mnRowDelta;
1091 SCTAB nDz = rCxt.mnTabDelta;
1092 SCCOL nCol1 = rCxt.maRange.aStart.Col(), nCol2 = rCxt.maRange.aEnd.Col();
1093 SCROW nRow1 = rCxt.maRange.aStart.Row(), nRow2 = rCxt.maRange.aEnd.Row();
1094 SCTAB nTab1 = rCxt.maRange.aStart.Tab(), nTab2 = rCxt.maRange.aEnd.Tab();
1095
1096 if ( ScRefUpdate::Update( this, eUpdateRefMode, nCol1,nRow1,nTab1, nCol2,nRow2,nTab2,
1097 nDx,nDy,nDz, theCol1,theRow1,theTab1, theCol2,theRow2,theTab2 ) )
1098 {
1099 aEmbedRange = ScRange( theCol1,theRow1,theTab1, theCol2,theRow2,theTab2 );
1100 }
1101 }
1102
1103 // After moving, no clipboard move ref-updates are possible
1104 if (rCxt.meMode != URM_COPY && IsClipboardSource())
1105 {
1106 ScDocument* pClipDoc = ScModule::GetClipDoc();
1107 if (pClipDoc)
1108 pClipDoc->GetClipParam().mbCutMode = false;
1109 }
1110}
1111
1112void ScDocument::UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
1113 const ScMarkData& rMark, ScDocument* pUndoDoc )
1114{
1115 OSL_ENSURE(pClipDoc->bIsClip, "UpdateTranspose: No Clip");
1116
1117 ScRange aSource;
1118 ScClipParam& rClipParam = pClipDoc->GetClipParam();
1119 if (!rClipParam.maRanges.empty())
1120 aSource = rClipParam.maRanges.front();
1121 ScAddress aDest = rDestPos;
1122
1123 SCTAB nClipTab = 0;
1124 for (SCTAB nDestTab = 0; nDestTab < GetTableCount() && maTabs[nDestTab]; nDestTab++)
1125 if (rMark.GetTableSelect(nDestTab))
1126 {
1127 while (!pClipDoc->maTabs[nClipTab]) nClipTab = (nClipTab+1) % (MAXTAB+1);
1128 aSource.aStart.SetTab( nClipTab );
1129 aSource.aEnd.SetTab( nClipTab );
1130 aDest.SetTab( nDestTab );
1131
1132 // Like UpdateReference
1133 if (pRangeName)
1134 pRangeName->UpdateTranspose( aSource, aDest ); // Before the cells!
1135 for (SCTAB i = 0; i < GetTableCount(); i++)
1136 if (maTabs[i])
1137 maTabs[i]->UpdateTranspose( aSource, aDest, pUndoDoc );
1138
1139 nClipTab = (nClipTab+1) % (MAXTAB+1);
1140 }
1141}
1142
1143void ScDocument::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
1144{
1145 //TODO: pDBCollection
1146 //TODO: pPivotCollection
1147 //TODO: UpdateChartRef
1148
1149 if (pRangeName)
1150 pRangeName->UpdateGrow( rArea, nGrowX, nGrowY );
1151
1152 for (SCTAB i = 0; i < GetTableCount() && maTabs[i]; i++)
1153 maTabs[i]->UpdateGrow( rArea, nGrowX, nGrowY );
1154}
1155
1156void ScDocument::Fill(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScProgress* pProgress, const ScMarkData& rMark,
1157 sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
1158 double nStepValue, double nMaxValue)
1159{
1160 PutInOrder( nCol1, nCol2 );
1161 PutInOrder( nRow1, nRow2 );
1162 const ScRange& aRange = rMark.GetMarkArea();
1163 SCTAB nMax = maTabs.size();
1164 for (const auto& rTab : rMark)
1165 {
1166 if (rTab >= nMax)
1167 break;
1168 if (maTabs[rTab])
1169 {
1170 maTabs[rTab]->Fill(nCol1, nRow1, nCol2, nRow2,
1171 nFillCount, eFillDir, eFillCmd, eFillDateCmd,
1172 nStepValue, tools::Duration(), nMaxValue, pProgress);
1173 RefreshAutoFilter(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), rTab);
1174 }
1175 }
1176}
1177
1178OUString ScDocument::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY )
1179{
1180 SCTAB nTab = rSource.aStart.Tab();
1181 if (nTab < GetTableCount() && maTabs[nTab])
1182 return maTabs[nTab]->GetAutoFillPreview( rSource, nEndX, nEndY );
1183
1184 return OUString();
1185}
1186
1187void ScDocument::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1188 sal_uInt16 nFormatNo, const ScMarkData& rMark )
1189{
1190 PutInOrder( nStartCol, nEndCol );
1191 PutInOrder( nStartRow, nEndRow );
1192 SCTAB nMax = maTabs.size();
1193 for (const auto& rTab : rMark)
1194 {
1195 if (rTab >= nMax)
1196 break;
1197 if (maTabs[rTab])
1198 maTabs[rTab]->AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo );
1199 }
1200}
1201
1202void ScDocument::GetAutoFormatData(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1203 ScAutoFormatData& rData)
1204{
1205 if (ScTable* pTable = FetchTable(nTab))
1206 {
1207 PutInOrder(nStartCol, nEndCol);
1208 PutInOrder(nStartRow, nEndRow);
1209 pTable->GetAutoFormatData(nStartCol, nStartRow, nEndCol, nEndRow, rData);
1210 }
1211}
1212
1214 SCCOL& rCol, SCROW& rRow )
1215{
1216 SvxSearchCmd nCommand = rSearchItem.GetCommand();
1217 bool bReplace = ( nCommand == SvxSearchCmd::REPLACE ||
1218 nCommand == SvxSearchCmd::REPLACE_ALL );
1219 if ( rSearchItem.GetBackward() )
1220 {
1221 if ( rSearchItem.GetRowDirection() )
1222 {
1223 if ( rSearchItem.GetPattern() )
1224 {
1225 rCol = MaxCol();
1226 rRow = MaxRow()+1;
1227 }
1228 else if ( bReplace )
1229 {
1230 rCol = MaxCol();
1231 rRow = MaxRow();
1232 }
1233 else
1234 {
1235 rCol = MaxCol()+1;
1236 rRow = MaxRow();
1237 }
1238 }
1239 else
1240 {
1241 if ( rSearchItem.GetPattern() )
1242 {
1243 rCol = MaxCol()+1;
1244 rRow = MaxRow();
1245 }
1246 else if ( bReplace )
1247 {
1248 rCol = MaxCol();
1249 rRow = MaxRow();
1250 }
1251 else
1252 {
1253 rCol = MaxCol();
1254 rRow = MaxRow()+1;
1255 }
1256 }
1257 }
1258 else
1259 {
1260 if ( rSearchItem.GetRowDirection() )
1261 {
1262 if ( rSearchItem.GetPattern() )
1263 {
1264 rCol = 0;
1265 rRow = SCROW(-1);
1266 }
1267 else if ( bReplace )
1268 {
1269 rCol = 0;
1270 rRow = 0;
1271 }
1272 else
1273 {
1274 rCol = SCCOL(-1);
1275 rRow = 0;
1276 }
1277 }
1278 else
1279 {
1280 if ( rSearchItem.GetPattern() )
1281 {
1282 rCol = SCCOL(-1);
1283 rRow = 0;
1284 }
1285 else if ( bReplace )
1286 {
1287 rCol = 0;
1288 rRow = 0;
1289 }
1290 else
1291 {
1292 rCol = 0;
1293 rRow = SCROW(-1);
1294 }
1295 }
1296 }
1297}
1298
1299// static
1301{
1302 return !rSearchItem.GetPattern() && (rSearchItem.GetCellType() != SvxSearchCellType::NOTE)
1303 && (rSearchItem.GetSearchOptions().searchString.isEmpty()
1304 || (rSearchItem.GetRegExp() && rSearchItem.GetSearchOptions().searchString == "^$"));
1305}
1306
1308 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, SCTAB& rTab,
1309 const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1310 OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped)
1311{
1312 // FIXME: Manage separated marks per table!
1313 bool bFound = false;
1314 if (rTab >= GetTableCount())
1315 OSL_FAIL("table out of range");
1316 if (ValidTab(rTab))
1317 {
1318 SCCOL nCol;
1319 SCROW nRow;
1320 SCTAB nTab;
1321 SvxSearchCmd nCommand = rSearchItem.GetCommand();
1322 if ( nCommand == SvxSearchCmd::FIND_ALL ||
1323 nCommand == SvxSearchCmd::REPLACE_ALL )
1324 {
1325 SCTAB nMax = maTabs.size();
1326 for (const auto& rMarkedTab : rMark)
1327 {
1328 if (rMarkedTab >= nMax)
1329 break;
1330 if (maTabs[rMarkedTab])
1331 {
1332 nCol = 0;
1333 nRow = 0;
1334 bFound |= maTabs[rMarkedTab]->SearchAndReplace(
1335 rSearchItem, nCol, nRow, rMark, rMatchedRanges, rUndoStr, pUndoDoc, bMatchedRangesWereClamped);
1336 }
1337 }
1338
1339 // Mark is set completely inside already
1340 }
1341 else
1342 {
1343 nCol = rCol;
1344 nRow = rRow;
1345 if (rSearchItem.GetBackward())
1346 {
1347 for (nTab = rTab; (nTab >= 0) && !bFound; nTab--)
1348 if (maTabs[nTab])
1349 {
1350 if (rMark.GetTableSelect(nTab))
1351 {
1352 bFound = maTabs[nTab]->SearchAndReplace(
1353 rSearchItem, nCol, nRow, rMark, rMatchedRanges, rUndoStr, pUndoDoc, bMatchedRangesWereClamped);
1354 if (bFound)
1355 {
1356 rCol = nCol;
1357 rRow = nRow;
1358 rTab = nTab;
1359 }
1360 else
1361 {
1363 rSearchItem, nCol, nRow );
1364
1365 // notify LibreOfficeKit about changed page
1367 {
1368 OString aPayload = OString::number(nTab);
1369 if (SfxViewShell* pViewShell = SfxViewShell::Current())
1370 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload);
1371 }
1372 }
1373 }
1374 }
1375 }
1376 else
1377 {
1378 for (nTab = rTab; (nTab < GetTableCount()) && !bFound; nTab++)
1379 if (maTabs[nTab])
1380 {
1381 if (rMark.GetTableSelect(nTab))
1382 {
1383 bFound = maTabs[nTab]->SearchAndReplace(
1384 rSearchItem, nCol, nRow, rMark, rMatchedRanges, rUndoStr, pUndoDoc, bMatchedRangesWereClamped);
1385 if (bFound)
1386 {
1387 rCol = nCol;
1388 rRow = nRow;
1389 rTab = nTab;
1390 }
1391 else
1392 {
1394 rSearchItem, nCol, nRow );
1395
1396 // notify LibreOfficeKit about changed page
1398 {
1399 OString aPayload = OString::number(nTab);
1400 if(SfxViewShell* pViewShell = SfxViewShell::Current())
1401 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload);
1402 }
1403 }
1404 }
1405 }
1406 }
1407 }
1408 }
1409 return bFound;
1410}
1411
1415bool ScDocument::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow )
1416{
1417 if (ScTable* pTable = FetchTable(nTab))
1418 return pTable->UpdateOutlineCol(nStartCol, nEndCol, bShow);
1419
1420 OSL_FAIL("missing tab");
1421 return false;
1422}
1423
1424bool ScDocument::UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow )
1425{
1426 if (ScTable* pTable = FetchTable(nTab))
1427 return pTable->UpdateOutlineRow(nStartRow, nEndRow, bShow);
1428
1429 OSL_FAIL("missing tab");
1430 return false;
1431}
1432
1434 SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
1435 ScProgress* pProgress, sc::ReorderParam* pUndo )
1436{
1437 if (ScTable* pTable = FetchTable(nTab))
1438 {
1439 bool bOldEnableIdle = IsIdleEnabled();
1440 EnableIdle(false);
1441 pTable->Sort(rSortParam, bKeepQuery, bUpdateRefs, pProgress, pUndo);
1442 EnableIdle(bOldEnableIdle);
1443 }
1444}
1445
1447{
1448 ScTable* pTable = FetchTable(rParam.maSortRange.aStart.Tab());
1449 if (!pTable)
1450 return;
1451
1452 bool bOldEnableIdle = IsIdleEnabled();
1453 EnableIdle(false);
1454 pTable->Reorder(rParam);
1455 EnableIdle(bOldEnableIdle);
1456}
1457
1459{
1460 if (ScTable* pTable = FetchTable(nTab))
1461 pTable->PrepareQuery(rQueryParam);
1462 else
1463 {
1464 OSL_FAIL("missing tab");
1465 }
1466}
1467
1468SCSIZE ScDocument::Query(SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub)
1469{
1470 if (ScTable* pTable = FetchTable(nTab))
1471 return pTable->Query(rQueryParam, bKeepSub);
1472
1473 OSL_FAIL("missing tab");
1474 return 0;
1475}
1476
1478{
1479 if (ScTable* pTable = FetchTable(nTab))
1480 return pTable->GetUpperCellString( nCol, nRow );
1481 else
1482 return OUString();
1483}
1484
1485bool ScDocument::CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam )
1486{
1487 if (ScTable* pTable = FetchTable(rRange.aStart.Tab()))
1488 return pTable->CreateQueryParam(rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), rQueryParam);
1489
1490 OSL_FAIL("missing tab");
1491 return false;
1492}
1493
1494bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab )
1495{
1496 const ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab, ScDBDataPortion::AREA );
1497 bool bHasAutoFilter = (pDBData != nullptr);
1498
1499 if ( pDBData )
1500 {
1501 if ( pDBData->HasHeader() )
1502 {
1503 SCCOL nCol;
1504 SCROW nRow;
1505 ScMF nFlag;
1506
1507 ScQueryParam aParam;
1508 pDBData->GetQueryParam( aParam );
1509 nRow = aParam.nRow1;
1510
1511 for ( nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAutoFilter; nCol++ )
1512 {
1513 nFlag = GetAttr( nCol, nRow, nCurTab, ATTR_MERGE_FLAG )->GetValue();
1514
1515 if ( !(nFlag & ScMF::Auto) )
1516 bHasAutoFilter = false;
1517 }
1518 }
1519 else
1520 bHasAutoFilter = false;
1521 }
1522
1523 return bHasAutoFilter;
1524}
1525
1526bool ScDocument::HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1527 SCTAB nTab )
1528{
1529 ScTable* pTable = FetchTable(nTab);
1530 return pTable && pTable->HasColHeader(nStartCol, nStartRow, nEndCol, nEndRow);
1531}
1532
1533bool ScDocument::HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1534 SCTAB nTab )
1535{
1536 ScTable* pTable = FetchTable(nTab);
1537 return pTable && pTable->HasRowHeader(nStartCol, nStartRow, nEndCol, nEndRow);
1538}
1539
1540void ScDocument::GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE& nSelected, SCSIZE& nTotal )
1541{
1542 nSelected = 0;
1543 nTotal = 0;
1544
1545 if (HasTable(nTab))
1546 {
1547 ScDBData* pDBData = GetDBAtCursor( nCol, nRow, nTab, ScDBDataPortion::AREA );
1548 if( pDBData && pDBData->HasAutoFilter() )
1549 pDBData->GetFilterSelCount( nSelected, nTotal );
1550 }
1551}
1552
1557 SCCOL nCol, SCROW nRow, SCTAB nTab, ScFilterEntries& rFilterEntries )
1558{
1559 if (!HasTable(nTab) || !pDBCollection)
1560 return;
1561
1562 ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ScDBDataPortion::AREA);
1563 if (!pDBData)
1564 return;
1565
1566 pDBData->ExtendDataArea(*this);
1567 SCTAB nAreaTab;
1568 SCCOL nStartCol;
1569 SCROW nStartRow;
1570 SCCOL nEndCol;
1571 SCROW nEndRow;
1572 pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
1573
1574 if (pDBData->HasHeader())
1575 ++nStartRow;
1576
1577 ScQueryParam aParam;
1578 pDBData->GetQueryParam( aParam );
1579
1580 // Return all filter entries, if a filter condition is connected with a boolean OR
1581 bool bFilter = true;
1582 SCSIZE nEntryCount = aParam.GetEntryCount();
1583 for ( SCSIZE i = 0; i < nEntryCount && aParam.GetEntry(i).bDoQuery; ++i )
1584 {
1585 ScQueryEntry& rEntry = aParam.GetEntry(i);
1586 if ( rEntry.eConnect != SC_AND )
1587 {
1588 bFilter = false;
1589 break;
1590 }
1591 }
1592
1593 if ( bFilter )
1594 {
1595 maTabs[nTab]->GetFilteredFilterEntries( nCol, nStartRow, nEndRow, aParam, rFilterEntries, bFilter );
1596 }
1597 else
1598 {
1599 maTabs[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rFilterEntries );
1600 }
1601
1602 sortAndRemoveDuplicates( rFilterEntries.maStrData, aParam.bCaseSens);
1603}
1604
1609 SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bCaseSens,
1610 ScFilterEntries& rFilterEntries )
1611{
1612 if (ScTable* pTable = FetchTable(nTab))
1613 {
1614 pTable->GetFilterEntries(nCol, nStartRow, nEndRow, rFilterEntries, true);
1615 sortAndRemoveDuplicates(rFilterEntries.maStrData, bCaseSens);
1616 }
1617}
1618
1623 SCCOL nCol, SCROW nRow, SCTAB nTab,
1624 std::vector<ScTypedStrData>& rStrings, bool bValidation )
1625{
1626 if( bValidation )
1627 {
1628 /* Try to generate the list from list validation. This part is skipped,
1629 if bValidation==false, because in that case this function is called to get
1630 cell values for auto completion on input. */
1631 sal_uInt32 nValidation = GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA )->GetValue();
1632 if( nValidation )
1633 {
1634 const ScValidationData* pData = GetValidationEntry( nValidation );
1635 if( pData && pData->FillSelectionList( rStrings, ScAddress( nCol, nRow, nTab ) ) )
1636 {
1637 if (pData->GetListType() == css::sheet::TableValidationVisibility::SORTEDASCENDING)
1638 sortAndRemoveDuplicates(rStrings, true/*bCaseSens*/);
1639
1640 return;
1641 }
1642 }
1643 }
1644
1645 if (!HasTable(nTab))
1646 return;
1647
1648 std::set<ScTypedStrData> aStrings;
1649 if (maTabs[nTab]->GetDataEntries(nCol, nRow, aStrings))
1650 {
1651 rStrings.insert(rStrings.end(), aStrings.begin(), aStrings.end());
1652 sortAndRemoveDuplicates(rStrings, true/*bCaseSens*/);
1653 }
1654}
1655
1660{
1661
1662 // Range name
1663 if ( pRangeName )
1664 {
1665 for (const auto& rEntry : *pRangeName)
1666 rStrings.insert(ScTypedStrData(rEntry.second->GetName(), 0.0, 0.0, ScTypedStrData::Name));
1667 }
1668
1669 // Database collection
1670 if ( pDBCollection )
1671 {
1672 const ScDBCollection::NamedDBs& rDBs = pDBCollection->getNamedDBs();
1673 for (const auto& rxDB : rDBs)
1674 rStrings.insert(ScTypedStrData(rxDB->GetName(), 0.0, 0.0, ScTypedStrData::DbName));
1675 }
1676
1677 // Content of name ranges
1678 ScRangePairList* pLists[2];
1679 pLists[0] = GetColNameRanges();
1680 pLists[1] = GetRowNameRanges();
1681 for (ScRangePairList* pList : pLists)
1682 {
1683 if (!pList)
1684 continue;
1685
1686 for ( size_t i = 0, nPairs = pList->size(); i < nPairs; ++i )
1687 {
1688 const ScRangePair & rPair = (*pList)[i];
1689 const ScRange & rRange = rPair.GetRange(0);
1690 ScCellIterator aIter( *this, rRange );
1691 for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
1692 {
1693 if (!aIter.hasString())
1694 continue;
1695
1696 OUString aStr = aIter.getString();
1697 rStrings.insert(ScTypedStrData(aStr, 0.0, 0.0, ScTypedStrData::Header));
1698 }
1699 }
1700 }
1701}
1702
1704{
1705 rRange = aEmbedRange;
1706}
1707
1709{
1710 tools::Rectangle aRect;
1711 ScTable* pTable = nullptr;
1713 pTable = maTabs[aEmbedRange.aStart.Tab()].get();
1714 else
1715 OSL_FAIL("table out of range");
1716 if (!pTable)
1717 {
1718 OSL_FAIL("GetEmbeddedRect without a table");
1719 }
1720 else
1721 {
1722 SCCOL i;
1723
1724 for (i=0; i<aEmbedRange.aStart.Col(); i++)
1725 aRect.AdjustLeft(pTable->GetColWidth(i) );
1726 aRect.AdjustTop(pTable->GetRowHeight( 0, aEmbedRange.aStart.Row() - 1) );
1727 aRect.SetRight( aRect.Left() );
1728 for (i=aEmbedRange.aStart.Col(); i<=aEmbedRange.aEnd.Col(); i++)
1729 aRect.AdjustRight(pTable->GetColWidth(i) );
1730 aRect.SetBottom( aRect.Top() );
1732
1734 }
1735 return aRect;
1736}
1737
1739{
1740 bIsEmbedded = true;
1741 aEmbedRange = rRange;
1742}
1743
1745{
1746 bIsEmbedded = false;
1747 aEmbedRange = ScRange();
1748}
1749
1754static bool lcl_AddTwipsWhile( tools::Long & rTwips, tools::Long nStopTwips, SCROW & rPosY, SCROW nEndRow, const ScTable * pTable, bool bHiddenAsZero )
1755{
1756 SCROW nRow = rPosY;
1757 bool bAdded = false;
1758 bool bStop = false;
1759 while (rTwips < nStopTwips && nRow <= nEndRow && !bStop)
1760 {
1761 SCROW nHeightEndRow;
1762 sal_uInt16 nHeight = pTable->GetRowHeight( nRow, nullptr, &nHeightEndRow, bHiddenAsZero );
1763 if (nHeightEndRow > nEndRow)
1764 nHeightEndRow = nEndRow;
1765 if (!nHeight)
1766 nRow = nHeightEndRow + 1;
1767 else
1768 {
1769 SCROW nRows = nHeightEndRow - nRow + 1;
1770 sal_Int64 nAdd = static_cast<sal_Int64>(nHeight) * nRows;
1771 if (nAdd + rTwips >= nStopTwips)
1772 {
1773 sal_Int64 nDiff = nAdd + rTwips - nStopTwips;
1774 nRows -= static_cast<SCROW>(nDiff / nHeight);
1775 nAdd = static_cast<sal_Int64>(nHeight) * nRows;
1776 // We're looking for a value that satisfies loop condition.
1777 if (nAdd + rTwips >= nStopTwips)
1778 {
1779 --nRows;
1780 nAdd -= nHeight;
1781 }
1782 bStop = true;
1783 }
1784 rTwips += static_cast<tools::Long>(nAdd);
1785 nRow += nRows;
1786 }
1787 }
1788 if (nRow > rPosY)
1789 {
1790 --nRow;
1791 bAdded = true;
1792 }
1793 rPosY = nRow;
1794 return bAdded;
1795}
1796
1797ScRange ScDocument::GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bHiddenAsZero ) const
1798{
1799 ScTable* pTable = nullptr;
1800 if (nTab < GetTableCount())
1801 pTable = maTabs[nTab].get();
1802 else
1803 OSL_FAIL("table out of range");
1804 if (!pTable)
1805 {
1806 OSL_FAIL("GetRange without a table");
1807 return ScRange();
1808 }
1809
1811 if ( IsNegativePage( nTab ) )
1812 ScDrawLayer::MirrorRectRTL( aPosRect ); // Always with positive (LTR) values
1813
1814 tools::Long nSize;
1815 tools::Long nTwips;
1816 tools::Long nAdd;
1817 bool bEnd;
1818
1819 nSize = 0;
1820 nTwips = aPosRect.Left();
1821
1822 SCCOL nX1 = 0;
1823 bEnd = false;
1824 while (!bEnd)
1825 {
1826 nAdd = pTable->GetColWidth(nX1, bHiddenAsZero);
1827 if (nSize+nAdd <= nTwips+1 && nX1<MaxCol())
1828 {
1829 nSize += nAdd;
1830 ++nX1;
1831 }
1832 else
1833 bEnd = true;
1834 }
1835
1836
1837 SCCOL nX2 = nX1;
1838 if (!aPosRect.IsEmpty())
1839 {
1840 bEnd = false;
1841 nTwips = aPosRect.Right();
1842 while (!bEnd)
1843 {
1844 nAdd = pTable->GetColWidth(nX2, bHiddenAsZero);
1845 if (nSize+nAdd < nTwips && nX2<MaxCol())
1846 {
1847 nSize += nAdd;
1848 ++nX2;
1849 }
1850 else
1851 bEnd = true;
1852 }
1853 }
1854
1855 nSize = 0;
1856 nTwips = aPosRect.Top();
1857
1858 SCROW nY1 = 0;
1859 // Was if(nSize+nAdd<=nTwips+1) inside loop => if(nSize+nAdd<nTwips+2)
1860 if (lcl_AddTwipsWhile( nSize, nTwips+2, nY1, MaxRow(), pTable, bHiddenAsZero) && nY1 < MaxRow())
1861 ++nY1; // original loop ended on last matched +1 unless that was rDoc.MaxRow()
1862
1863 SCROW nY2 = nY1;
1864 if (!aPosRect.IsEmpty())
1865 {
1866 nTwips = aPosRect.Bottom();
1867 // Was if(nSize+nAdd<nTwips) inside loop => if(nSize+nAdd<nTwips)
1868 if (lcl_AddTwipsWhile( nSize, nTwips, nY2, MaxRow(), pTable, bHiddenAsZero) && nY2 < MaxRow())
1869 ++nY2; // original loop ended on last matched +1 unless that was rDoc.MaxRow()
1870 }
1871
1872 return ScRange( nX1,nY1,nTab, nX2,nY2,nTab );
1873}
1874
1875void ScDocument::SetEmbedded( SCTAB nTab, const tools::Rectangle& rRect ) // From VisArea (1/100 mm)
1876{
1877 bIsEmbedded = true;
1878 aEmbedRange = GetRange( nTab, rRect );
1879}
1880
1882{
1883 return pDocProtection.get();
1884}
1885
1887{
1888 if (pProtect)
1889 pDocProtection.reset(new ScDocProtection(*pProtect));
1890 else
1891 pDocProtection.reset();
1892}
1893
1895{
1896 return pDocProtection && pDocProtection->isProtected();
1897}
1898
1900{
1901 // Import into read-only document is possible
1903}
1904
1906{
1907 if (const ScTable* pTable = FetchTable(nTab))
1908 return pTable->IsProtected();
1909
1910 OSL_FAIL("Wrong table number");
1911 return false;
1912}
1913
1915{
1916 if (const ScTable* pTable = FetchTable(nTab))
1917 return pTable->GetProtection();
1918
1919 return nullptr;
1920}
1921
1923{
1924 if (ScTable* pTable = FetchTable(nTab))
1925 pTable->SetProtection(pProtect);
1926}
1927
1929{
1930 if (!HasTable(nTabSrc) || !HasTable(nTabDest))
1931 return;
1932
1933 maTabs[nTabDest]->SetProtection( maTabs[nTabSrc]->GetProtection() );
1934}
1935
1937{
1938 assert(pDocOptions && "No DocOptions! :-(");
1939 return *pDocOptions;
1940}
1941
1943{
1944 assert(pDocOptions && "No DocOptions! :-(");
1945
1946 *pDocOptions = rOpt;
1947 if (mxPoolHelper)
1948 mxPoolHelper->SetFormTableOpt(rOpt);
1949}
1950
1952{
1953 assert(pViewOptions && "No ViewOptions! :-(");
1954 return *pViewOptions;
1955}
1956
1958{
1959 assert(pViewOptions && "No ViewOptions! :-(");
1960 *pViewOptions = rOpt;
1961}
1962
1964{
1965 rLatin = eLanguage;
1966 rCjk = eCjkLanguage;
1967 rCtl = eCtlLanguage;
1968}
1969
1971{
1972 eLanguage = eLatin;
1973 eCjkLanguage = eCjk;
1974 eCtlLanguage = eCtl;
1975 if ( mxPoolHelper.is() )
1976 {
1977 ScDocumentPool* pPool = mxPoolHelper->GetDocPool();
1981 }
1982
1983 UpdateDrawLanguages(); // Set edit engine defaults in drawing layer pool
1984}
1985
1986tools::Rectangle ScDocument::GetMMRect( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero ) const
1987{
1988 if (!HasTable(nTab))
1989 {
1990 OSL_FAIL("GetMMRect: wrong table");
1991 return tools::Rectangle(0,0,0,0);
1992 }
1993
1994 SCCOL i;
1995 tools::Rectangle aRect;
1996
1997 for (i=0; i<nStartCol; i++)
1998 aRect.AdjustLeft(GetColWidth(i,nTab, bHiddenAsZero ) );
1999 aRect.AdjustTop(GetRowHeight( 0, nStartRow-1, nTab, bHiddenAsZero ) );
2000
2001 aRect.SetRight( aRect.Left() );
2002 aRect.SetBottom( aRect.Top() );
2003
2004 for (i=nStartCol; i<=nEndCol; i++)
2005 aRect.AdjustRight(GetColWidth(i,nTab, bHiddenAsZero) );
2006 aRect.AdjustBottom(GetRowHeight( nStartRow, nEndRow, nTab, bHiddenAsZero ) );
2007
2009
2010 if ( IsNegativePage( nTab ) )
2012
2013 return aRect;
2014}
2015
2016void ScDocument::SetExtDocOptions( std::unique_ptr<ScExtDocOptions> pNewOptions )
2017{
2018 pExtDocOptions = std::move(pNewOptions);
2019}
2020
2021void ScDocument::SetClipOptions(std::unique_ptr<ScClipOptions> pClipOptions)
2022{
2023 mpClipOptions = std::move(pClipOptions);
2024}
2025
2026void ScDocument::DoMergeContents( SCCOL nStartCol, SCROW nStartRow,
2027 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab )
2028{
2029 OUStringBuffer aTotal;
2030 OUString aCellStr;
2031 SCCOL nCol;
2032 SCROW nRow;
2033 for (nRow=nStartRow; nRow<=nEndRow; nRow++)
2034 for (nCol=nStartCol; nCol<=nEndCol; nCol++)
2035 {
2036 aCellStr = GetString(nCol, nRow, nTab);
2037 if (!aCellStr.isEmpty())
2038 {
2039 if (!aTotal.isEmpty())
2040 aTotal.append(' ');
2041 aTotal.append(aCellStr);
2042 }
2043 if (nCol != nStartCol || nRow != nStartRow)
2044 SetString(nCol,nRow,nTab,"");
2045 }
2046
2047 SetString(nStartCol,nStartRow,nTab,aTotal.makeStringAndClear());
2048}
2049
2050void ScDocument::DoEmptyBlock( SCCOL nStartCol, SCROW nStartRow,
2051 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab )
2052{
2053 SCCOL nCol;
2054 SCROW nRow;
2055 for (nRow=nStartRow; nRow<=nEndRow; nRow++)
2056 for (nCol=nStartCol; nCol<=nEndCol; nCol++)
2057 { // empty block except first cell
2058 if (nCol != nStartCol || nRow != nStartRow)
2059 SetString(nCol,nRow,nTab,"");
2060 }
2061}
2062
2063void ScDocument::DoMerge( SCCOL nStartCol, SCROW nStartRow,
2064 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bDeleteCaptions )
2065{
2066 ScTable* pTab = FetchTable(nTab);
2067 if (!pTab)
2068 return;
2069
2070 pTab->SetMergedCells(nStartCol, nStartRow, nEndCol, nEndRow);
2071
2072 // Remove all covered notes (removed captions are collected by drawing undo if active)
2074 if( nStartCol < nEndCol )
2075 DeleteAreaTab( nStartCol + 1, nStartRow, nEndCol, nStartRow, nTab, nDelFlag );
2076 if( nStartRow < nEndRow )
2077 DeleteAreaTab( nStartCol, nStartRow + 1, nEndCol, nEndRow, nTab, nDelFlag );
2078}
2079
2081{
2082 const ScMergeAttr* pAttr = GetAttr( nCol, nRow, nTab, ATTR_MERGE );
2083
2084 if ( pAttr->GetColMerge() <= 1 && pAttr->GetRowMerge() <= 1 )
2085 return;
2086
2087 SCCOL nEndCol = nCol + pAttr->GetColMerge() - 1;
2088 SCROW nEndRow = nRow + pAttr->GetRowMerge() - 1;
2089
2090 RemoveFlagsTab( nCol, nRow, nEndCol, nEndRow, nTab, ScMF::Hor | ScMF::Ver );
2091
2092 const ScMergeAttr* pDefAttr = &mxPoolHelper->GetDocPool()->GetDefaultItem( ATTR_MERGE );
2093 ApplyAttr( nCol, nRow, nTab, *pDefAttr );
2094}
2095
2097 SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow ) const
2098{
2099 if (HasTable(nTab))
2100 maTabs[nTab]->ExtendPrintArea(pDev, nStartCol, nStartRow, rEndCol, nEndRow);
2101}
2102
2104{
2105 if (const ScTable* pTable = FetchTable(nTab))
2106 return pTable->GetPatternCount( nCol );
2107 else
2108 return 0;
2109}
2110
2111SCSIZE ScDocument::GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const
2112{
2113 if (const ScTable* pTable = FetchTable(nTab))
2114 return pTable->GetPatternCount(nCol, nRow1, nRow2);
2115 return 0;
2116}
2117
2119{
2120 if (ScTable* pTable = FetchTable(nTab))
2121 pTable->ReservePatternCount(nCol, nReserve);
2122}
2123
2125{
2126 rParam = mSheetSortParams[ nTab ];
2127}
2128
2129void ScDocument::SetSortParam( const ScSortParam& rParam, SCTAB nTab )
2130{
2131 mSheetSortParams[ nTab ] = rParam;
2132}
2133
2135{
2136 return maTabs[nTab]->ClampToAllocatedColumns(nCol);
2137}
2138
2140{
2141 return maTabs[nTab]->GetAllocatedColumnsCount();
2142}
2143
2144/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * pName
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
const SCTAB MAXTAB
Definition: address.hxx:70
const SCTAB SC_TAB_APPEND
Definition: address.hxx:90
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
void PutInOrder(T &nStart, T &nEnd)
Definition: address.hxx:150
ScMF
Definition: attrib.hxx:34
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
SCCOL Col() const
Definition: address.hxx:279
Walk through all cells in an area.
Definition: dociter.hxx:206
CellType getType() const
Definition: dociter.hxx:233
ScFormulaCell * getFormulaCell()
Definition: dociter.hxx:236
bool hasString() const
Definition: dociter.cxx:994
OUString getString() const
Definition: dociter.cxx:968
All current charts in the calc will be locked in constructor and unlocked in destructor.
Definition: chartlock.hxx:36
Stores global named database ranges.
Definition: dbdata.hxx:243
bool HasAutoFilter() const
Definition: dbdata.hxx:212
bool HasHeader() const
Definition: dbdata.hxx:136
void GetFilterSelCount(SCSIZE &nSelected, SCSIZE &nTotal)
Definition: dbdata.cxx:981
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:298
const OUString & GetUpperName() const
Definition: dbdata.hxx:128
SC_DLLPUBLIC void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: dbdata.cxx:422
void ExtendDataArea(const ScDocument &rDoc)
Definition: dbdata.cxx:649
bool IsError() const
Definition: tablink.cxx:577
ScDocument * GetDocument()
Definition: tablink.cxx:572
SC_DLLPUBLIC bool InsertTab(SCTAB nPos, const OUString &rName, bool bExternalDocument=false, bool bUndoDeleteTab=false)
Definition: document.cxx:485
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:432
SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const
Definition: documen3.cxx:2139
SC_DLLPUBLIC bool RemoveFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:4980
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4161
void UpdateGrow(const ScRange &rArea, SCCOL nGrowX, SCROW nGrowY)
Definition: documen3.cxx:1143
bool IsAddressInRangeName(RangeNameScope eScope, const ScAddress &rAddress)
Definition: documen3.cxx:196
SC_DLLPUBLIC void GetRangeNameMap(std::map< OUString, ScRangeName * > &rRangeName)
Definition: documen3.cxx:149
bool UpdateOutlineCol(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow)
Adapt Outline.
Definition: documen3.cxx:1415
void GetAutoFormatData(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData &rData)
Definition: documen3.cxx:1202
SC_DLLPUBLIC ScRange GetRange(SCTAB nTab, const tools::Rectangle &rMMRect, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1797
bool RefreshAutoFilter(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: document.cxx:5660
tools::Rectangle GetEmbeddedRect() const
Definition: documen3.cxx:1708
SC_DLLPUBLIC bool LinkExternalTab(SCTAB &nTab, const OUString &aDocTab, const OUString &aFileName, const OUString &aTabName)
Definition: documen3.cxx:566
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4122
void SC_DLLPUBLIC GetSortParam(ScSortParam &rParam, SCTAB nTab)
Definition: documen3.cxx:2124
SC_DLLPUBLIC void SetAllRangeNames(const std::map< OUString, ScRangeName > &rRangeMap)
Definition: documen3.cxx:126
SC_DLLPUBLIC OUString GetLinkTab(SCTAB nTab) const
Definition: documen3.cxx:530
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1914
void UpdateRefAreaLinks(UpdateRefMode eUpdateRefMode, const ScRange &r, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: documen8.cxx:1078
SC_DLLPUBLIC void CopyUpdated(ScDocument *pPosDoc, ScDocument *pDestDoc)
From this document this method copies the cells of positions at which there are also cells in pPosDoc...
Definition: documen3.cxx:803
bool SetOutlineTable(SCTAB nTab, const ScOutlineTable *pNewOutline)
Definition: documen3.cxx:754
SC_DLLPUBLIC ScRangeName * GetRangeName() const
Definition: documen3.cxx:178
SC_DLLPUBLIC sal_uLong TransferTab(ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew=true, bool bResultsOnly=false)
Definition: documen2.cxx:946
SC_DLLPUBLIC ScTable * FetchTable(SCTAB nTab)
Definition: document.cxx:2509
ScFormulaParserPool & GetFormulaParserPool() const
Returns the pool containing external formula parsers.
Definition: documen3.cxx:654
SC_DLLPUBLIC bool IsDocProtected() const
Definition: documen3.cxx:1894
void SetRangeName(SCTAB nTab, std::unique_ptr< ScRangeName > pNew)
Definition: documen3.cxx:185
std::unique_ptr< ScUnoListenerCalls > pUnoListenerCalls
Definition: document.hxx:396
SC_DLLPUBLIC void Fill(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScProgress *pProgress, const ScMarkData &rMark, sal_uInt64 nFillCount, FillDir eFillDir=FILL_TO_BOTTOM, FillCmd eFillCmd=FILL_LINEAR, FillDateCmd eFillDateCmd=FILL_DAY, double nStepValue=1.0, double nMaxValue=1E307)
Definition: documen3.cxx:1156
ScClipParam & GetClipParam()
Definition: document.cxx:2564
std::unique_ptr< ScClipOptions > mpClipOptions
Definition: document.hxx:426
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
Definition: documen3.cxx:449
void PrepareQuery(SCTAB nTab, ScQueryParam &rQueryParam)
Definition: documen3.cxx:1458
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:244
std::unique_ptr< ScDocOptions > pDocOptions
Definition: document.hxx:424
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1905
bool IsIdleEnabled() const
Definition: document.hxx:2207
LanguageType eCtlLanguage
Definition: document.hxx:454
ScRange aEmbedRange
Definition: document.hxx:438
ScRangePairList * GetRowNameRanges()
Definition: document.hxx:820
void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab, ScMarkData &rDestMark, bool bResetMark=true, ScScenarioFlags nNeededBits=ScScenarioFlags::NONE) const
Definition: documen3.cxx:854
void RemoveSubTotals(SCTAB nTab, ScSubTotalParam &rParam)
Definition: documen3.cxx:773
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
ScDPObject * GetDPAtBlock(const ScRange &rBlock) const
Definition: documen3.cxx:391
std::unique_ptr< ScDPCollection > pDPCollection
Definition: document.hxx:383
SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: documen3.cxx:438
SC_DLLPUBLIC const ScValidationData * GetValidationEntry(sal_uInt32 nIndex) const
Definition: documen4.cxx:873
bool IsClipboard() const
Definition: document.hxx:1594
const ScDBData * GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
Definition: documen3.cxx:322
const ScSheetEvents * GetSheetEvents(SCTAB nTab) const
Definition: documen3.cxx:661
std::unique_ptr< ScFormulaParserPool > mxFormulaParserPool
Definition: document.hxx:415
SC_DLLPUBLIC SCROW GetMaxRowCount() const
Definition: document.hxx:895
SC_DLLPUBLIC void DoMergeContents(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:2026
formula::FormulaGrammar::Grammar eGrammar
Definition: document.hxx:545
OUString GetLinkOpt(SCTAB nTab) const
Definition: documen3.cxx:523
rtl::Reference< ScPoolHelper > mxPoolHelper
Definition: document.hxx:358
bool InsertNewRangeName(const OUString &rName, const ScAddress &rPos, const OUString &rExpr)
Insert a new named expression to the global scope.
Definition: documen3.cxx:218
void GetSearchAndReplaceStart(const SvxSearchItem &rSearchItem, SCCOL &rCol, SCROW &rRow)
Definition: documen3.cxx:1213
void SetCalcNotification(SCTAB nTab)
Definition: documen3.cxx:722
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:492
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
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
SC_DLLPUBLIC bool HasPivotTable() const
Definition: documen3.cxx:360
void BeginUnoRefUndo()
Definition: documen3.cxx:990
bool HasLink(std::u16string_view rDoc, std::u16string_view rFilter, std::u16string_view rOptions) const
Definition: documen3.cxx:552
void AddUnoRefChange(sal_Int64 nId, const ScRangeList &rOldRanges)
Definition: documen3.cxx:1002
SC_DLLPUBLIC void DoMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bDeleteCaptions=true)
Definition: documen3.cxx:2063
void UpdateReference(sc::RefUpdateContext &rCxt, ScDocument *pUndoDoc=nullptr, bool bIncludeDraw=true, bool bUpdateNoteCaptionPos=true)
Definition: documen3.cxx:1008
bool DoSubTotals(SCTAB nTab, ScSubTotalParam &rParam)
Definition: documen3.cxx:779
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Definition: documen3.cxx:338
SfxBindings * GetViewBindings()
Definition: documen8.cxx:1183
std::unique_ptr< SfxBroadcaster > pUnoBroadcaster
Definition: document.hxx:395
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: documen3.cxx:1942
bool HasScenarioRange(SCTAB nTab, const ScRange &rRange) const
Definition: documen3.cxx:866
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:982
void RepaintRange(const ScRange &rRange)
Definition: documen8.cxx:689
std::unique_ptr< ScValidationDataList > pValidationList
Definition: document.hxx:376
void CopyScenario(SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario=false)
Definition: documen3.cxx:811
bool IsDocEditable() const
Definition: documen3.cxx:1899
ScRangePairListRef xRowNameRanges
Definition: document.hxx:421
bool bImportingXML
Definition: document.hxx:505
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
Definition: documen3.cxx:625
std::unique_ptr< ScUnoRefList > EndUnoRefUndo()
Definition: documen3.cxx:996
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:469
SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap &rRangeNames) const
Get all range names that are local to each table.
Definition: documen3.cxx:107
void RemoveMerge(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: documen3.cxx:2080
SC_DLLPUBLIC void GetFilterEntriesArea(SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bCaseSens, ScFilterEntries &rFilterEntries)
Entries for Filter dialog.
Definition: documen3.cxx:1608
void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest)
Definition: documen3.cxx:1928
void ReservePatternCount(SCTAB nTab, SCCOL nCol, SCSIZE nReserve)
Definition: documen3.cxx:2118
SC_DLLPUBLIC const ScViewOptions & GetViewOptions() const
Definition: documen3.cxx:1951
SC_DLLPUBLIC void DoEmptyBlock(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:2050
void AddUnoObject(SfxListener &rObject)
Definition: documen3.cxx:901
void ResetCalcNotifications()
Definition: documen3.cxx:729
void SetChartListenerCollection(std::unique_ptr< ScChartListenerCollection >, bool bSetChartRangeLists)
Definition: documen3.cxx:412
std::unique_ptr< ScDetOpList > pDetOpList
Definition: document.hxx:393
SC_DLLPUBLIC bool CreateQueryParam(const ScRange &rRange, ScQueryParam &rQueryParam)
Definition: documen3.cxx:1485
OUString GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: documen3.cxx:1477
void SetLanguage(LanguageType eLatin, LanguageType eCjk, LanguageType eCtl)
Definition: documen3.cxx:1970
std::unique_ptr< ScExtDocOptions > pExtDocOptions
Definition: document.hxx:425
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
Definition: document.cxx:3391
ScRangePairList * GetColNameRanges()
Definition: document.hxx:819
void GetFilterEntries(SCCOL nCol, SCROW nRow, SCTAB nTab, ScFilterEntries &rFilterEntries)
Get a list of unique strings to use in filtering criteria.
Definition: documen3.cxx:1556
TableContainer maTabs
Definition: document.hxx:378
SC_DLLPUBLIC void SetGrammar(formula::FormulaGrammar::Grammar eGram)
Definition: documen3.cxx:497
bool HasAnyCalcNotification() const
Definition: documen3.cxx:706
LanguageType eLanguage
Definition: document.hxx:452
bool bIsClip
Definition: document.hxx:494
SC_DLLPUBLIC bool HasColHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:1526
std::unique_ptr< ScExternalRefManager > pExternalRefMgr
Definition: document.hxx:410
void SetAllFormulasDirty(const sc::SetFormulaDirtyContext &rCxt)
Definition: document.cxx:3819
bool UpdateOutlineRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow)
Definition: documen3.cxx:1424
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1957
void GetDataEntries(SCCOL nCol, SCROW nRow, SCTAB nTab, std::vector< ScTypedStrData > &rStrings, bool bValidation=false)
Entries for selection list listbox (no numbers/formulas)
Definition: documen3.cxx:1622
SC_DLLPUBLIC const ScRangeList * GetScenarioRanges(SCTAB nTab) const
Definition: documen3.cxx:872
void DoAutoOutline(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:760
void SC_DLLPUBLIC SetSortParam(const ScSortParam &rParam, SCTAB nTab)
Definition: documen3.cxx:2129
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:1010
void Reorder(const sc::ReorderParam &rParam)
Definition: documen3.cxx:1446
void MarkUsedExternalReferences()
Definition: documen3.cxx:639
std::unique_ptr< ScUnoRefList > pUnoRefUndoList
Definition: document.hxx:397
SC_DLLPUBLIC const ScRangeData * GetRangeAtBlock(const ScRange &rBlock, OUString &rName, bool *pSheetLocal=nullptr) const
Definition: documen3.cxx:238
void GetEmbedded(ScRange &rRange) const
Definition: documen3.cxx:1703
bool HasCalcNotification(SCTAB nTab) const
Definition: documen3.cxx:715
SCSIZE GetPatternCount(SCTAB nTab, SCCOL nCol) const
Definition: documen3.cxx:2103
bool bIsEmbedded
Definition: document.hxx:499
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen3.cxx:377
void EnableIdle(bool bDo)
Definition: document.hxx:2208
void StopTemporaryChartLock()
Definition: documen3.cxx:406
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4741
SC_DLLPUBLIC ScDocProtection * GetDocProtection() const
Definition: documen3.cxx:1881
SC_DLLPUBLIC void GetLanguage(LanguageType &rLatin, LanguageType &rCjk, LanguageType &rCtl) const
Definition: documen3.cxx:1963
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
Definition: documen3.cxx:737
void ResetEmbedded()
Definition: documen3.cxx:1744
SCSIZE Query(SCTAB nTab, const ScQueryParam &rQueryParam, bool bKeepSub)
Definition: documen3.cxx:1468
bool bInUnoBroadcast
Definition: document.hxx:542
bool TestRemoveSubTotals(SCTAB nTab, const ScSubTotalParam &rParam)
Definition: documen3.cxx:767
SC_DLLPUBLIC SCCOL ClampToAllocatedColumns(SCTAB nTab, SCCOL nCol) const
Definition: documen3.cxx:2134
void SetSheetEvents(SCTAB nTab, std::unique_ptr< ScSheetEvents > pNew)
Definition: documen3.cxx:668
void SetClipOptions(std::unique_ptr< ScClipOptions > pClipOptions)
Definition: documen3.cxx:2021
bool HasSheetEventScript(SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents=false) const
Definition: documen3.cxx:674
LanguageType eCjkLanguage
Definition: document.hxx:453
sal_uLong GetLinkRefreshDelay(SCTAB nTab) const
Definition: documen3.cxx:537
void SetLink(SCTAB nTab, ScLinkMode nMode, const OUString &rDoc, const OUString &rFilter, const OUString &rOptions, const OUString &rTabName, sal_uLong nRefreshDelay)
Definition: documen3.cxx:544
SC_DLLPUBLIC void SetExtDocOptions(std::unique_ptr< ScExtDocOptions > pNewOptions)
Definition: documen3.cxx:2016
void AddUnoListenerCall(const css::uno::Reference< css::util::XModifyListener > &rListener, const css::lang::EventObject &rEvent)
Definition: documen3.cxx:980
bool HasAnySheetEventScript(ScSheetEventId nEvent, bool bWithVbaEvents=false) const
Definition: documen3.cxx:697
std::unique_ptr< ScDBCollection > pDBCollection
Definition: document.hxx:382
SC_DLLPUBLIC void SetActiveScenario(SCTAB nTab, bool bActive)
Definition: documen3.cxx:886
SC_DLLPUBLIC void SetDocProtection(const ScDocProtection *pProtect)
Definition: documen3.cxx:1886
SC_DLLPUBLIC bool HasRowHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:1533
std::map< SCTAB, ScSortParam > mSheetSortParams
Definition: document.hxx:2700
std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock
Definition: document.hxx:384
OUString GetAutoFillPreview(const ScRange &rSource, SCCOL nEndX, SCROW nEndY)
Definition: documen3.cxx:1178
bool TestCopyScenario(SCTAB nSrcTab, SCTAB nDestTab) const
Definition: documen3.cxx:892
bool SearchAndReplace(const SvxSearchItem &rSearchItem, SCCOL &rCol, SCROW &rRow, SCTAB &rTab, const ScMarkData &rMark, ScRangeList &rMatchedRanges, OUString &rUndoStr, ScDocument *pUndoDoc, bool &bMatchedRangesWereClamped)
Definition: documen3.cxx:1307
void AutoFormat(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_uInt16 nFormatNo, const ScMarkData &rMark)
Definition: documen3.cxx:1187
static bool IsEmptyCellSearch(const SvxSearchItem &rSearchItem)
Definition: documen3.cxx:1300
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
Definition: document.cxx:1920
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
Definition: document.cxx:3505
void RemoveUnoObject(SfxListener &rObject)
Definition: documen3.cxx:909
void UpdateChartRef(UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: documen5.cxx:394
SC_DLLPUBLIC OUString GetLinkDoc(SCTAB nTab) const
Definition: documen3.cxx:509
void UpdateDrawLanguages()
Definition: documen9.cxx:182
SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection *pProtect)
Definition: documen3.cxx:1922
bool IsLinked(SCTAB nTab) const
Definition: documen3.cxx:486
void RefreshDirtyTableColumnNames()
Definition: documen3.cxx:354
void SetDBCollection(std::unique_ptr< ScDBCollection > pNewDBCollection, bool bRemoveAutoFilter=false)
Definition: documen3.cxx:275
bool IsInExternalReferenceMarking() const
Definition: documen3.cxx:634
std::unique_ptr< ScDocProtection > pDocProtection
Definition: document.hxx:407
bool bInUnoListenerCall
Definition: document.hxx:543
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:2502
css::uno::Reference< css::script::vba::XVBAEventProcessor > mxVbaEvents
Definition: document.hxx:444
bool HasSubTotalCells(const ScRange &rRange)
Definition: documen3.cxx:785
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:231
SfxObjectShell * mpShell
Definition: document.hxx:371
void GetFilterSelCount(SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE &nSelected, SCSIZE &nTotal)
Definition: documen3.cxx:1540
std::unique_ptr< ScViewOptions > pViewOptions
Definition: document.hxx:423
SC_DLLPUBLIC void SetTabBgColor(SCTAB nTab, const Color &rColor)
Definition: documen3.cxx:456
OUString GetLinkFlt(SCTAB nTab) const
Definition: documen3.cxx:516
void ExtendPrintArea(OutputDevice *pDev, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW nEndRow) const
Find the maximum column position that contains printable data for the specified row range.
Definition: documen3.cxx:2096
SC_DLLPUBLIC void SetScenario(SCTAB nTab, bool bFlag)
Definition: documen3.cxx:426
bool IsClipboardSource() const
Definition: document.cxx:2577
bool ValidRange(const ScRange &rRange) const
Definition: document.hxx:903
bool mbChangeReadOnlyEnabled
Definition: document.hxx:551
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4684
bool HasAutoFilter(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: documen3.cxx:1494
ScRangePairListRef xColNameRanges
Definition: document.hxx:420
void GetScenarioFlags(SCTAB nTab, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:480
SC_DLLPUBLIC void UpdateTranspose(const ScAddress &rDestPos, ScDocument *pClipDoc, const ScMarkData &rMark, ScDocument *pUndoDoc)
Definition: documen3.cxx:1112
SC_DLLPUBLIC SCCOL GetMaxColCount() const
Definition: document.hxx:894
SC_DLLPUBLIC ScLkUpdMode GetLinkMode() const
Definition: document.hxx:2260
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1936
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
Definition: documen3.cxx:365
std::unique_ptr< ScRangeName > pRangeName
Definition: document.hxx:381
void Sort(SCTAB nTab, const ScSortParam &rSortParam, bool bKeepQuery, bool bUpdateRefs, ScProgress *pProgress, sc::ReorderParam *pUndo)
Sort a range of data.
Definition: documen3.cxx:1433
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
Definition: documen3.cxx:880
SC_DLLPUBLIC bool IsDefaultTabBgColor(SCTAB nTab) const
Definition: documen3.cxx:462
SC_DLLPUBLIC tools::Rectangle GetMMRect(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1986
void BroadcastUno(const SfxHint &rHint)
Definition: documen3.cxx:952
void GetFormulaEntries(ScTypedCaseStrSet &rStrings)
Entries for Formula auto input.
Definition: documen3.cxx:1659
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
std::unique_ptr< ScChartListenerCollection > pChartListenerCollection
Definition: document.hxx:391
void SetEmbedded(const ScRange &rRange)
Definition: documen3.cxx:1738
static void MirrorRectRTL(tools::Rectangle &rRect)
Definition: drwlayer.cxx:2377
bool IsSubTotal() const
Stores the used instances of the FilterFormulaParser service implementations, mapped by the formula n...
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
const ScRange & GetMarkArea() const
Definition: markdata.hxx:83
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:169
void ResetMark()
Definition: markdata.cxx:80
void SetAreaTab(SCTAB nTab)
Definition: markdata.cxx:149
SCCOL GetColMerge() const
Definition: attrib.hxx:71
SCROW GetRowMerge() const
Definition: attrib.hxx:72
static ScDocument * GetClipDoc()
Definition: scmod.cxx:688
ScRange & front()
Definition: rangelst.hxx:92
bool empty() const
Definition: rangelst.hxx:88
size_t size() const
Definition: rangelst.hxx:89
SC_DLLPUBLIC ScRangeData * findByIndex(sal_uInt16 i) const
Definition: rangenam.cxx:716
::std::map< SCTAB, const ScRangeName * > TabNameCopyMap
Map that stores non-managed pointers to ScRangeName instances.
Definition: rangenam.hxx:201
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
Definition: rangenam.cxx:802
SC_DLLPUBLIC const ScRangeData * findByRange(const ScRange &rRange) const
Definition: rangenam.cxx:697
const ScRange & GetRange(sal_uInt16 n) const
Definition: address.hxx:810
ScAddress aEnd
Definition: address.hxx:498
bool Contains(const ScAddress &) const
is Address& fully in Range?
Definition: address.hxx:718
ScAddress aStart
Definition: address.hxx:497
static ScRefUpdateRes Update(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz, SCCOL &theCol1, SCROW &theRow1, SCTAB &theTab1, SCCOL &theCol2, SCROW &theRow2, SCTAB &theTab2)
Definition: refupdat.cxx:188
const OUString * GetScript(ScSheetEventId nEvent) const
Definition: sheetevents.cxx:99
static sal_Int32 GetVbaDocumentEventId(ScSheetEventId nEvent)
Definition: sheetevents.cxx:58
static sal_Int32 GetVbaSheetEventId(ScSheetEventId nEvent)
Definition: sheetevents.cxx:39
sheet protection state container
bool IsActiveScenario() const
Definition: table.hxx:382
bool IsScenario() const
Definition: table.hxx:371
bool HasRowHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const
Definition: table3.cxx:2984
bool GetCalcNotification() const
Definition: table.hxx:363
bool HasScenarioRange(const ScRange &rRange) const
Definition: table2.cxx:1597
sal_uInt16 GetColWidth(SCCOL nCol, bool bHiddenAsZero=true) const
Definition: table2.cxx:3455
sal_uInt16 GetRowHeight(SCROW nRow, SCROW *pStartRow, SCROW *pEndRow, bool bHiddenAsZero=true) const
Definition: table2.cxx:3553
bool SetOutlineTable(const ScOutlineTable *pNewOutline)
Definition: table2.cxx:91
void SetMergedCells(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: table2.cxx:2345
bool HasColHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const
Definition: table3.cxx:2955
bool IsLinked() const
Definition: table.hxx:385
bool DoSubTotals(ScSubTotalParam &rParam)
Definition: table3.cxx:2119
void Reorder(const sc::ReorderParam &rParam)
Definition: table3.cxx:1907
bool TestRemoveSubTotals(const ScSubTotalParam &rParam)
Definition: table3.cxx:1982
ScUnoListenerCalls stores notifications to XModifyListener that can't be processed during BroadcastUn...
List of RefUpdate changes made to UNO objects during ScUpdateRefHint broadcast.
Definition: unoreflist.hxx:43
void Invalidate(sal_uInt16 nId)
SfxHintId GetId() const
void SetPoolDefaultItem(const SfxPoolItem &)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
bool IsReadOnly() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
SvxSearchCmd GetCommand() const
const i18nutil::SearchOptions2 & GetSearchOptions() const
bool GetRowDirection() const
SvxSearchCellType GetCellType() const
bool GetBackward() const
bool GetRegExp() const
bool GetPattern() const
static AddressConvention extractRefConvention(const Grammar eGrammar)
Temporarily switch on/off auto calculation mode.
Definition: scopetools.hxx:27
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, std::u16string_view rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
constexpr tools::Long Top() const
constexpr void SetRight(tools::Long v)
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
int nCount
ScDBDataPortion
Enum used to indicate which portion of the DBArea is to be considered.
Definition: dbdata.hxx:41
@ AREA
entire area
static bool lcl_AddTwipsWhile(tools::Long &rTwips, tools::Long nStopTwips, SCROW &rPosY, SCROW nEndRow, const ScTable *pTable, bool bHiddenAsZero)
Similar to ScViewData::AddPixelsWhile(), but add height twips and only while result is less than nSto...
Definition: documen3.cxx:1754
@ CORE
Definition: document.hxx:317
RangeNameScope
Definition: document.hxx:270
@ GLOBAL
Definition: document.hxx:271
@ SC_AND
Definition: global.hxx:855
@ CELLTYPE_FORMULA
Definition: global.hxx:276
UpdateRefMode
Definition: global.hxx:301
@ URM_COPY
Definition: global.hxx:303
@ URM_INSDEL
Definition: global.hxx:302
InsertDeleteFlags
Definition: global.hxx:149
@ NOTE
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
@ NOCAPTIONS
Sparklines in a cell.
FillDateCmd
Definition: global.hxx:334
ScLinkMode
Definition: global.hxx:215
ScScenarioFlags
Definition: global.hxx:226
FillCmd
Definition: global.hxx:317
FillDir
Definition: global.hxx:309
constexpr OUStringLiteral STR_GLOBAL_RANGE_NAME
Definition: globalnames.hxx:17
sal_Int32 nIndex
void * p
sal_Int64 n
SvBaseLink * pLink
aStr
std::unique_ptr< sal_Int32[]> pData
int i
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
sal_Int16 nId
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
constexpr TypedWhichId< SvxLanguageItem > ATTR_CTL_FONT_LANGUAGE(120)
constexpr TypedWhichId< SvxLanguageItem > ATTR_FONT_LANGUAGE(110)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
constexpr TypedWhichId< SvxLanguageItem > ATTR_CJK_FONT_LANGUAGE(115)
#define SC_MOD()
Definition: scmod.hxx:247
ScSheetEventId
Definition: sheetevents.hxx:27
sal_uIntPtr sal_uLong
SvxSearchCmd
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
Definition: clipparam.hxx:31
ScRangeList maRanges
Definition: clipparam.hxx:34
bool mbCutMode
Definition: clipparam.hxx:36
std::vector< ScTypedStrData > maStrData
A pretty assertion that checks that the relevant bits in the @nFlags are not set on the document at e...
Definition: document.hxx:2761
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:34
ScQueryConnect eConnect
Definition: queryentry.hxx:63
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
Definition: queryparam.cxx:116
SC_DLLPUBLIC SCSIZE GetEntryCount() const
Definition: queryparam.cxx:111
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.
ScRange maSortRange
This sort range already takes into account the presence or absence of header row / column i....
Definition: sortparam.hxx:160
std::set< ScTypedStrData, ScTypedStrData::LessCaseSensitive > ScTypedCaseStrSet
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17