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