1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <vcl/idle.hxx>
23 #include <comphelper/errcode.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <vcl/vclptr.hxx>
26 #include "patattr.hxx"
28 #include "interpretercontext.hxx"
29 #include "rangelst.hxx"
30 #include "rangenam.hxx"
31 #include "recursionhelper.hxx"
32 #include "tabopparams.hxx"
34 #include <formula/grammar.hxx>
35 #include <formula/types.hxx>
36 #include "typedstrdata.hxx"
37 #include "calcmacros.hxx"
38 #include "calcconfig.hxx"
39 #include "sheetlimits.hxx"
40 #include <o3tl/deleter.hxx>
41 #include <o3tl/sorted_vector.hxx>
42 #include <svl/hint.hxx>
43 #include <svl/typedwhich.hxx>
44 #include <svl/zforlist.hxx>
45 #include <tools/gen.hxx>
46 #include <tools/solar.h>
51 #include <shared_mutex>
54 #include <unordered_map>
57 #include "markdata.hxx"
58 #include "drwlayer.hxx"
60 namespace com::sun::star::chart2
{ class XChartDocument
; }
64 enum class SvtScriptType
: sal_uInt8
;
66 enum class FormulaError
: sal_uInt16
;
67 enum class CharCompressType
;
68 enum class EEHorizontalTextDirection
;
69 namespace editeng
{ class SvxBorderLine
; }
70 namespace formula
{ struct VectorRefArray
; }
73 class SharedStringPool
;
76 namespace tools
{ class Guid
; }
80 struct FormulaGroupContext
;
81 class StartListeningContext
;
82 class EndListeningContext
;
83 class CopyFromClipContext
;
85 class RangeColumnSpanSet
;
86 struct ColumnBlockPosition
;
87 struct RefUpdateContext
;
88 class EditTextIterator
;
90 class DocumentStreamAccess
;
91 class DocumentLinkManager
;
94 class RowHeightContext
;
95 struct SetFormulaDirtyContext
;
98 class FormulaGroupAreaListener
;
100 class UpdatedRangeNames
;
101 class TableColumnBlockPositionSet
;
102 class ColumnIterator
;
103 class ExternalDataMapper
;
105 class SparklineGroup
;
114 class SfxBroadcaster
;
117 class SfxObjectShell
;
122 class SfxStyleSheetBase
;
123 class SvMemoryStream
;
124 class SvxBoxInfoItem
;
126 class SvxForbiddenCharactersTable
;
133 class ScAutoFormatData
;
134 class ScBroadcastAreaSlotMachine
;
135 class ScChangeViewSettings
;
136 class ScChartListenerCollection
;
139 class ScConditionalFormat
;
140 class ScConditionalFormatList
;
141 class ScDBCollection
;
146 class ScDocProtection
;
147 class ScDocumentPool
;
149 class ScExtDocOptions
;
150 class ScExternalRefManager
;
152 class ScMacroManager
;
153 class ScOutlineTable
;
154 class ScPrintRangeSaver
;
156 class ScStyleSheetPool
;
158 class ScTableProtection
;
160 class ScValidationData
;
161 class ScValidationDataList
;
164 class ScEditEngineDefaulter
;
165 class ScFieldEditEngine
;
166 class ScNoteEditEngine
;
168 class ScDPCollection
;
170 class ScScriptTypeData
;
173 class ScRefreshTimerControl
;
174 class ScUnoListenerCalls
;
176 class ScRecursionHelper
;
181 class ScAutoNameCache
;
182 class ScTemporaryChartLock
;
184 struct ScLookupCacheMap
;
185 class ScSortedRangeCache
;
186 struct ScSortedRangeCacheMap
;
188 class ScFormulaParserPool
;
190 class ScRowBreakIterator
;
191 struct ScSetStringParam
;
192 struct ScColWidthParam
;
196 class ScEditDataArray
;
197 class EditTextObject
;
198 struct ScRefCellValue
;
200 struct ScSubTotalParam
;
203 class SvtBroadcaster
;
204 enum class ScDBDataPortion
;
205 enum class ScSheetEventId
;
207 class ScColumnsRange
;
208 struct ScFilterEntries
;
209 typedef o3tl::sorted_vector
<sal_uInt32
> ScCondFormatIndexes
;
210 struct ScSheetLimits
;
211 struct ScDataAreaExtras
;
216 typedef std::map
<OUString
, BitmapEx
> IconSetBitmapMap
;
220 namespace com::sun::star
{
225 class XBreakIterator
;
228 class XModifyListener
;
231 class XEmbeddedObject
;
233 namespace script::vba
{
234 class XVBAEventProcessor
;
237 struct TablePageBreakData
;
247 #define SC_DOC_NEW 0xFFFF
249 #define SC_MACROCALL_ALLOWED 0
251 #define SC_ASIANKERNING_INVALID 0xff
258 SCDOCMODE_FUNCTIONACCESS
261 enum CommentCaptionState
263 ALLSHOWN
, // All comments captions are shown
264 ALLHIDDEN
, // All comments captions are hidden
265 MIXED
// There are comments in shown and hidden.
270 GLOBAL
, // A range name can be defined
271 SHEET
// with two scope on Manage Names dialog.
274 /// Represents the type of sheet geometry data.
275 enum class SheetGeomType
277 SIZES
, // Column widths or row heights.
278 HIDDEN
, // Hidden columns/rows.
279 FILTERED
, // Filtered columns/rows.
280 GROUPS
// Grouping of columns/rows.
287 sal_uInt64 nCellCount
;
288 sal_uInt64 nFormulaCount
;
289 sal_uInt16 nPageCount
;
300 const sal_uInt8 SC_DDE_DEFAULT
= 0;
301 const sal_uInt8 SC_DDE_ENGLISH
= 1;
302 const sal_uInt8 SC_DDE_TEXT
= 2;
303 const sal_uInt8 SC_DDE_IGNOREMODE
= 255; /// For usage in FindDdeLink() only!
305 // During threaded calculation fields being mutated are kept in this struct
306 struct ScDocumentThreadSpecific
308 std::unique_ptr
<ScRecursionHelper
> xRecursionHelper
; // information for recursive and iterative cell formulas
309 ScInterpreterContext
* pContext
= nullptr; // references the context passed around for easier access
312 /// Enumeration to determine which pieces of the code should not be mutated when set.
313 enum ScMutationGuardFlags
316 CORE
= 0x0001, /// Core calc data structures should not be mutated
319 typedef std::unique_ptr
<ScTable
, o3tl::default_delete
<ScTable
>> ScTableUniquePtr
;
323 friend class ScValueIterator
;
324 friend class ScHorizontalValueIterator
;
325 friend class ScDBQueryDataIterator
;
326 friend class ScCellIterator
;
327 template< ScQueryCellIteratorAccess accessType
, ScQueryCellIteratorType queryType
>
328 friend class ScQueryCellIteratorBase
;
329 template< ScQueryCellIteratorAccess accessType
>
330 friend class ScQueryCellIteratorAccessSpecific
;
331 friend class ScHorizontalCellIterator
;
332 friend class ScHorizontalAttrIterator
;
333 friend class ScDocAttrIterator
;
334 friend class ScAttrRectIterator
;
335 friend class ScDocShell
;
336 friend class ScDocRowHeightUpdater
;
337 friend class ScColumnTextWidthIterator
;
338 friend class ScTable
;
339 friend class ScColumn
;
340 friend struct ScRefCellValue
;
341 friend class ScDocumentImport
;
342 friend class sc::EditTextIterator
;
343 friend struct ScMutationGuard
;
344 friend struct ScMutationDisable
;
346 typedef std::vector
<ScTableUniquePtr
> TableContainer
;
349 enum class HardRecalcState
351 OFF
, /// normal calculation of dependencies
352 TEMPORARY
, /// CalcAll() without broadcast/notify but setting up new listeners
353 ETERNAL
/// no new listeners are setup, no broadcast/notify
357 rtl::Reference
<ScPoolHelper
> mxPoolHelper
;
359 std::shared_ptr
<svl::SharedStringPool
> mpCellStringPool
;
360 std::unique_ptr
<sc::DocumentLinkManager
> mpDocLinkMgr
;
362 std::shared_ptr
<sc::FormulaGroupContext
> mpFormulaGroupCxt
;
363 bool mbFormulaGroupCxtBlockDiscard
;
365 ScCalcConfig maCalcConfig
;
367 ScUndoManager
* mpUndoManager
;
368 std::unique_ptr
<ScFieldEditEngine
> mpEditEngine
; // uses pEditPool from xPoolHelper
369 std::unique_ptr
<ScNoteEditEngine
> mpNoteEngine
; // uses pEditPool from xPoolHelper
370 SfxObjectShell
* mpShell
;
371 VclPtr
<SfxPrinter
> mpPrinter
;
372 VclPtr
<VirtualDevice
> mpVirtualDevice_100th_mm
;
373 std::unique_ptr
<ScDrawLayer
> mpDrawLayer
; // SdrModel
374 rtl::Reference
<XColorList
> pColorList
;
375 std::unique_ptr
<ScValidationDataList
> pValidationList
; // validity
376 SvNumberFormatterIndexTable
* pFormatExchangeList
; // for application of number formats
377 TableContainer maTabs
;
378 rtl::Reference
<ScSheetLimits
> mxSheetLimits
;
379 std::vector
<OUString
> maTabNames
; // for undo document, we need the information tab name <-> index
380 mutable std::unique_ptr
<ScRangeName
> pRangeName
;
381 std::unique_ptr
<ScDBCollection
> pDBCollection
;
382 std::unique_ptr
<ScDPCollection
> pDPCollection
;
383 std::unique_ptr
< ScTemporaryChartLock
> apTemporaryChartLock
;
384 std::unique_ptr
<ScPatternAttr
> pSelectionAttr
; // Attributes of a block
385 ScFormulaCell
* pFormulaTree
; // formula tree (start)
386 ScFormulaCell
* pEOFormulaTree
; // formula tree (end), last cell
387 ScFormulaCell
* pFormulaTrack
; // BroadcastTrack (start)
388 ScFormulaCell
* pEOFormulaTrack
; // BroadcastTrack (end), last cell
389 std::unique_ptr
<ScBroadcastAreaSlotMachine
> pBASM
; // BroadcastAreas
390 std::unique_ptr
<ScChartListenerCollection
> pChartListenerCollection
;
391 std::unique_ptr
<SvMemoryStream
> pClipData
;
392 std::unique_ptr
<ScDetOpList
> pDetOpList
;
393 std::unique_ptr
<ScChangeTrack
> pChangeTrack
;
394 std::unique_ptr
<SfxBroadcaster
> pUnoBroadcaster
;
395 std::unique_ptr
<ScUnoListenerCalls
> pUnoListenerCalls
;
396 std::unique_ptr
<ScUnoRefList
> pUnoRefUndoList
;
397 std::unique_ptr
<ScChangeViewSettings
> pChangeViewSettings
;
398 std::unique_ptr
<ScScriptTypeData
> pScriptTypeData
;
399 std::unique_ptr
<ScRefreshTimerControl
> pRefreshTimerControl
;
400 std::shared_ptr
<SvxForbiddenCharactersTable
> xForbiddenCharacters
;
401 std::unique_ptr
<ScDBData
> mpAnonymousDBData
;
402 std::unique_ptr
<sc::ExternalDataMapper
> mpDataMapper
;
404 std::unique_ptr
<ScFieldEditEngine
> pCacheFieldEditEngine
;
406 std::unique_ptr
<ScDocProtection
> pDocProtection
;
407 std::unique_ptr
<ScClipParam
> mpClipParam
;
409 std::unique_ptr
<ScExternalRefManager
> pExternalRefMgr
;
410 std::unique_ptr
<ScMacroManager
> mpMacroMgr
;
412 // mutable for lazy construction
413 mutable std::unique_ptr
< ScFormulaParserPool
>
414 mxFormulaParserPool
; /// Pool for all external formula parsers used by this document.
416 OUString aDocName
; // optional: name of document
417 OUString aDocCodeName
; // optional: name of document (twice?)
418 OUString maFileURL
; // file URL for copy & paste
419 ScRangePairListRef xColNameRanges
;
420 ScRangePairListRef xRowNameRanges
;
422 std::unique_ptr
<ScViewOptions
> pViewOptions
; // view options
423 std::unique_ptr
<ScDocOptions
> pDocOptions
; // document options
424 std::unique_ptr
<ScExtDocOptions
> pExtDocOptions
; // for import etc.
425 std::unique_ptr
<ScClipOptions
> mpClipOptions
; // clipboard options
426 std::unique_ptr
<ScConsolidateParam
> pConsolidateDlgData
;
428 std::unique_ptr
<ScAutoNameCache
> pAutoNameCache
; // for automatic name lookup during CompileXML
430 std::unique_ptr
<SfxItemSet
> pPreviewFont
; // convert to std::unique_ptr or whatever
431 ScStyleSheet
* pPreviewCellStyle
;
432 ScMarkData maPreviewSelection
;
433 sal_Int64 nUnoObjectId
; // counted up for UNO objects
435 ErrCode nRangeOverflowType
; // used in (xml) loading for overflow warnings
438 ScAddress aCurTextWidthCalcPos
;
442 css::uno::Reference
< css::script::vba::XVBAEventProcessor
>
445 /// list of ScInterpreterTableOpParams currently in use
446 std::vector
<ScInterpreterTableOpParams
*> m_TableOpList
;
447 ScInterpreterTableOpParams aLastTableOpParams
; // remember last params
451 LanguageType eLanguage
; // default language
452 LanguageType eCjkLanguage
; // default language for asian text
453 LanguageType eCtlLanguage
; // default language for complex text
454 rtl_TextEncoding eSrcSet
; // during reading: source character set
456 /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
457 documents, GRAM_ODFF for ODF 1.2 documents. */
458 formula::FormulaGrammar::Grammar eStorageGrammar
;
460 sal_uInt64 nFormulaCodeInTree
; // formula RPN in the formula tree
461 sal_uInt64 nXMLImportedFormulaCount
; // progress count during XML import
462 sal_uInt16 nInterpretLevel
; // >0 if in interpreter
463 sal_uInt16 nMacroInterpretLevel
; // >0 if macro in interpreter
464 sal_uInt16 nInterpreterTableOpLevel
; // >0 if in interpreter TableOp
466 ScDocumentThreadSpecific maNonThreaded
;
468 // There can be only one ScDocument being calculated in a thread at a time, so we can use a
469 // plain thread_local static member.
470 thread_local
static ScDocumentThreadSpecific maThreadSpecific
;
472 mutable ScInterpreterContext maInterpreterContext
;
474 std::shared_mutex mScLookupMutex
; // protection for thread-unsafe parts of handling ScLookup
475 std::unique_ptr
<ScSortedRangeCacheMap
> mxScSortedRangeCache
; // cache for unsorted lookups
477 static const sal_uInt16 nSrcVer
; // file version (load/save)
478 sal_uInt16 nFormulaTrackCount
;
479 HardRecalcState eHardRecalcState
; // off, temporary, eternal
480 SCTAB nVisibleTab
; // for OLE etc., don't use inside ScDocument
481 SCCOL nPosLeft
; // for OLE etc., don't use inside ScDocument
482 SCROW nPosTop
; // for OLE etc., don't use inside ScDocument
484 ScLkUpdMode eLinkMode
;
486 bool bAutoCalc
; // calculate automatically
487 bool bAutoCalcShellDisabled
; // in/from/for ScDocShell disabled
488 // are there ForcedFormulas which have to be calculated
489 // in interaction with ScDocShell SetDocumentModified,
490 // AutoCalcShellDisabled and TrackFormulas
491 bool bForcedFormulaPending
;
492 bool bCalculatingFormulaTree
;
495 bool bIsFunctionAccess
;
496 bool bIsVisible
; // set from view ctor
498 bool bIsEmbedded
; // display/adjust Embedded area?
500 // no broadcast, construct no listener during insert from a different
501 // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad
502 bool bInsertingFromOtherDoc
;
504 bool bImportingXML
; // special handling of formula text
505 bool bCalcingAfterLoad
; // in CalcAfterLoad TRUE
506 // don't construct/destruct listeners temporarily
509 bool bInLinkUpdate
; // TableLink or AreaLink
510 bool bChartListenerCollectionNeedsUpdate
;
511 // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever)
512 bool bHasForcedFormulas
;
513 // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore)
515 // expand reference if insert column/row takes place at the border
517 // is fetched in each UpdateReference from InputOptions,
518 // assigned, and restored at the end of UpdateReference
520 // for detective update, is set for each change of a formula
521 bool bDetectiveDirty
;
522 // If the pointer is set, formula cells will not be automatically grouped into shared formula groups,
523 // instead the range will be extended to contain all such cells.
524 std::unique_ptr
< ScRange
> pDelayedFormulaGrouping
;
525 // If non-empty, ScColumn::StartListeningFormulaCells() calls may be delayed using this,
526 // avoiding repeated calling for the same cells in the given range. The function will be called once
527 // later for all the cells in the range.
528 std::unordered_map
< ScColumn
*, std::pair
<SCROW
, SCROW
>> pDelayedStartListeningFormulaCells
;
529 // Cells will not delete their broadcasters if delayed, avoiding possible extensive mdds vector changes.
530 bool bDelayedDeletingBroadcasters
;
532 bool bLinkFormulaNeedingCheck
; // valid only after loading, for ocDde and ocWebservice
534 CharCompressType nAsianCompression
;
535 sal_uInt8 nAsianKerning
;
537 bool bPastingDrawFromOtherDoc
;
539 sal_uInt8 nInDdeLinkUpdate
; // originating DDE links (stacked bool)
541 bool bInUnoBroadcast
;
542 bool bInUnoListenerCall
;
543 sal_uInt32 nAdjustHeightLock
;
544 formula::FormulaGrammar::Grammar eGrammar
;
546 mutable bool bStyleSheetUsageInvalid
;
548 bool mbUndoEnabled
:1;
549 bool mbExecuteLinkEnabled
:1;
550 bool mbChangeReadOnlyEnabled
:1; // allow changes in read-only document (for API import filters)
551 bool mbStreamValidLocked
:1;
552 bool mbUserInteractionEnabled
:1; // whether or not to launch any kind of interactive dialogs.
554 sal_Int16 mnNamedRangesLockCount
;
556 std::set
<ScFormulaCell
*> maSubTotalCells
;
559 bool mbEmbedFonts
: 1;
560 bool mbEmbedUsedFontsOnly
: 1;
561 bool mbEmbedFontScriptLatin
: 1;
562 bool mbEmbedFontScriptAsian
: 1;
563 bool mbEmbedFontScriptComplex
: 1;
565 sal_Int32 mnImagePreferredDPI
;
567 std::unique_ptr
<sc::IconSetBitmapMap
> m_pIconSetBitmapMap
;
569 bool mbTrackFormulasPending
: 1;
570 bool mbFinalTrackFormulas
: 1;
571 // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress.
572 bool mbDocShellRecalc
: 1;
573 // This indicates if a ScOutputData::LayoutStrings() is in progress.
574 bool mbLayoutStrings
: 1;
576 size_t mnMutationGuardFlags
;
579 bool IsCellInChangeTrack(const ScAddress
&cell
,Color
*pColCellBorder
);
580 void GetCellChangeTrackNote(const ScAddress
&cell
, OUString
&strTrackText
, bool &pbLeftEdge
);
582 bool IsEmbedFonts() const { return mbEmbedFonts
; }
583 bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly
; }
584 bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin
; }
585 bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian
; }
586 bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex
; }
588 void SetEmbedFonts(bool bUse
) { mbEmbedFonts
= bUse
; }
589 void SetEmbedUsedFontsOnly(bool bUse
) { mbEmbedUsedFontsOnly
= bUse
; }
590 void SetEmbedFontScriptLatin(bool bUse
) { mbEmbedFontScriptLatin
= bUse
; }
591 void SetEmbedFontScriptAsian(bool bUse
) { mbEmbedFontScriptAsian
= bUse
; }
592 void SetEmbedFontScriptComplex(bool bUse
) { mbEmbedFontScriptComplex
= bUse
; }
594 void SetImagePreferredDPI(sal_Int32 nValue
) { mnImagePreferredDPI
= nValue
; }
595 sal_Int32
GetImagePreferredDPI() { return mnImagePreferredDPI
; }
597 SC_DLLPUBLIC sal_uInt64
GetCellCount() const; // all cells
598 SC_DLLPUBLIC sal_uInt64
GetFormulaGroupCount() const; // all cells
599 sal_uInt64
GetCodeCount() const; // RPN-Code in formulas
600 DECL_LINK( GetUserDefinedColor
, sal_uInt16
, Color
* );
603 SC_DLLPUBLIC
ScDocument( ScDocumentMode eMode
= SCDOCMODE_DOCUMENT
,
604 SfxObjectShell
* pDocShell
= nullptr );
605 SC_DLLPUBLIC
~ScDocument();
607 void SetName( const OUString
& r
) { aDocName
= r
; }
608 const OUString
& GetCodeName() const { return aDocCodeName
; }
609 void SetCodeName( const OUString
& r
) { aDocCodeName
= r
; }
610 const OUString
& GetFileURL() const { return maFileURL
; }
612 void GetDocStat( ScDocStat
& rDocStat
);
614 SC_DLLPUBLIC
void InitDrawLayer( SfxObjectShell
* pDocShell
= nullptr );
616 ScInterpreterContext
& GetNonThreadedContext() const
618 assert(!IsThreadedGroupCalcInProgress());
619 return maInterpreterContext
;
621 // Uses thread_local.
622 ScInterpreterContext
& GetThreadedContext() const
624 return IsThreadedGroupCalcInProgress() ? *maThreadSpecific
.pContext
: GetNonThreadedContext();
626 void SetupContextFromNonThreadedContext( ScInterpreterContext
& threadedContext
, int threadNumber
);
627 void MergeContextBackIntoNonThreadedContext( ScInterpreterContext
& threadedContext
, int threadNumber
);
628 void SetThreadedGroupCalcInProgress( bool set
) { (void)this; ScGlobal::bThreadedGroupCalcInProgress
= set
; }
629 bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress
; }
631 SC_DLLPUBLIC
sfx2::LinkManager
* GetLinkManager();
632 SC_DLLPUBLIC
const sfx2::LinkManager
* GetLinkManager() const;
634 sc::DocumentLinkManager
& GetDocLinkManager();
635 const sc::DocumentLinkManager
& GetDocLinkManager() const;
637 SC_DLLPUBLIC
const ScDocOptions
& GetDocOptions() const;
638 SC_DLLPUBLIC
void SetDocOptions( const ScDocOptions
& rOpt
);
639 SC_DLLPUBLIC
const ScViewOptions
& GetViewOptions() const;
640 SC_DLLPUBLIC
void SetViewOptions( const ScViewOptions
& rOpt
);
641 void SetPrintOptions();
643 ScExtDocOptions
* GetExtDocOptions() { return pExtDocOptions
.get(); }
644 SC_DLLPUBLIC
void SetExtDocOptions( std::unique_ptr
<ScExtDocOptions
> pNewOptions
);
646 ScClipOptions
* GetClipOptions() { return mpClipOptions
.get(); }
647 void SetClipOptions(std::unique_ptr
<ScClipOptions
> pClipOptions
);
649 SC_DLLPUBLIC
void GetLanguage( LanguageType
& rLatin
, LanguageType
& rCjk
, LanguageType
& rCtl
) const;
650 void SetLanguage( LanguageType eLatin
, LanguageType eCjk
, LanguageType eCtl
);
652 void SetConsolidateDlgData( std::unique_ptr
<ScConsolidateParam
> pData
);
653 const ScConsolidateParam
* GetConsolidateDlgData() const { return pConsolidateDlgData
.get(); }
655 void Clear( bool bFromDestructor
= false );
657 std::unique_ptr
<ScFieldEditEngine
> CreateFieldEditEngine();
658 void DisposeFieldEditEngine(std::unique_ptr
<ScFieldEditEngine
>& rpEditEngine
);
661 * Get all range names that are local to each table. It only returns
662 * non-empty range name set.
664 SC_DLLPUBLIC
void GetAllTabRangeNames(ScRangeName::TabNameCopyMap
& rRangeNames
) const;
665 SC_DLLPUBLIC
void SetAllRangeNames(const std::map
<OUString
, ScRangeName
>& rRangeMap
);
666 SC_DLLPUBLIC
void GetRangeNameMap(std::map
<OUString
, ScRangeName
*>& rRangeName
);
667 SC_DLLPUBLIC ScRangeName
* GetRangeName(SCTAB nTab
) const;
668 SC_DLLPUBLIC ScRangeName
* GetRangeName() const;
669 void SetRangeName(SCTAB nTab
, std::unique_ptr
<ScRangeName
> pNew
);
670 void SetRangeName( std::unique_ptr
<ScRangeName
> pNewRangeName
);
671 bool IsAddressInRangeName( RangeNameScope eScope
, const ScAddress
& rAddress
);
673 /** Find a named expression / range name in either global or a local scope.
675 If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab.
677 Index of named expression / range name.
678 @return nullptr if indexed name not found.
680 ScRangeData
* FindRangeNameBySheetAndIndex( SCTAB nTab
, sal_uInt16 nIndex
) const;
682 /** Recursively find all named expressions that directly or indirectly
683 (nested) reference a given sheet, starting from a given named
684 expression nTokenTab/nTokenIndex.
686 Used to collect all named expressions/ranges that will need to be
687 copied along when copying sheets.
689 The different tab/sheets passed cater for the situation that a sheet is
690 copied and was already inserted and global names are already adjusted
691 but the sheet-local names of the shifted original sheet are not yet. If
692 no sheet was inserted and global and local names' references not
693 updated yet, then all 4 tab arguments would be identical.
696 Tab/sheet on which to find the name, -1 if global scope.
697 For example obtained from ocName token.
700 Index of named expression. For example obtained from ocName token.
703 Tab to check if used in global names.
706 Tab to check if used in sheet-local names.
709 The original tab of the copied sheet, used as sheet-local
710 base position for relative references.
712 @param nOldTokenTabReplacement
713 The replacement to use for relative references if the name
714 encountered uses nOldTokenTab as base position.
717 FALSE if collecting names for a sheet to be copied to another
718 document. Then all names encountered are considered to be
719 referencing the sheet. Else TRUE if collecting names to be
720 copied into the same document.
723 Recursion guard, initialize with 0.
725 bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames
& rIndexes
,
726 SCTAB nTokenTab
, const sal_uInt16 nTokenIndex
,
727 SCTAB nGlobalRefTab
, SCTAB nLocalRefTab
, SCTAB nOldTokenTab
, SCTAB nOldTokenTabReplacement
,
728 bool bSameDoc
, int nRecursion
) const;
730 /** If necessary (name references sheet rOldPos.Tab()) copy and adjust
731 named expression/range from sheet-local to sheet-local, or global to
732 sheet-local if bGlobalNamesToLocal==true.
734 Also copies nested names and adjusts the ocName tokens of the calling name.
737 On entry, the original sheet of the named expression/range, <0 global.
738 On return TRUE, the new sheet. Else unchanged.
741 On entry, the original index of the named expression/range.
742 On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged.
745 On entry, the pointer to the original named expression/range.
746 On return TRUE, the pointer to the new copied name, or nullptr if hits happened.
749 New position of formula cell if called for that, else new base
750 position of a to be created new name adjusted for Tab.
751 rNewPos.nTab MUST point to the new sheet copied to.
754 Old position of formula cell if called for that, else base
755 position of the existing name adjusted for Tab.
756 rOldPos.nTab MUST point to the old sheet copied from.
758 @param bGlobalNamesToLocal
759 If TRUE, affected global names are copied to sheet-local names.
760 If FALSE, global names are copied to global names in another document.
762 @param bUsedByFormula
763 If TRUE, forces a global name to be affected/used.
764 If FALSE, a global name is only affected if it evaluates to be
765 referencing the sheet.
767 @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex.
768 FALSE if nothing to be done.
770 bool CopyAdjustRangeName( SCTAB
& rSheet
, sal_uInt16
& rIndex
, ScRangeData
*& rpRangeData
, ScDocument
& rNewDoc
,
771 const ScAddress
& rNewPos
, const ScAddress
& rOldPos
, const bool bGlobalNamesToLocal
,
772 const bool bUsedByFormula
) const;
775 * Call this immediately before updating all named ranges.
777 SC_DLLPUBLIC
void PreprocessAllRangeNamesUpdate( const std::map
<OUString
, ScRangeName
>& rRangeMap
);
778 SC_DLLPUBLIC
void PreprocessRangeNameUpdate();
779 SC_DLLPUBLIC
void PreprocessDBDataUpdate();
781 * Call this immediately after updating named ranges.
783 SC_DLLPUBLIC
void CompileHybridFormula();
786 * Insert a new named expression to the global scope.
788 * @param rName name for the expression.
789 * @param rPos base position.
790 * @param rExpr formula expression to be associated with the name. The
791 * current grammar is used to compile this expression.
793 * @return true if inserted successfully, false otherwise.
795 bool InsertNewRangeName( const OUString
& rName
, const ScAddress
& rPos
, const OUString
& rExpr
);
798 * Insert a new named expression to a sheet-local scope.
800 * @param nTab sheet for local scope.
801 * @param rName name for the expression.
802 * @param rPos base position.
803 * @param rExpr formula expression to be associated with the name. The
804 * current grammar is used to compile this expression.
806 * @return true if inserted successfully, false otherwise.
808 bool InsertNewRangeName( SCTAB nTab
, const OUString
& rName
, const ScAddress
& rPos
, const OUString
& rExpr
);
810 /** Obtain the sheet separator corresponding to the document's grammar.
812 @return '.' for our own grammars, '!' for Excel grammars.
814 SC_DLLPUBLIC sal_Unicode
GetSheetSeparator() const;
816 SCTAB
GetMaxTableNumber() const { return static_cast<SCTAB
>(maTabs
.size()) - 1; }
818 ScRangePairList
* GetColNameRanges() { return xColNameRanges
.get(); }
819 ScRangePairList
* GetRowNameRanges() { return xRowNameRanges
.get(); }
820 ScRangePairListRef
& GetColNameRangesRef() { return xColNameRanges
; }
821 ScRangePairListRef
& GetRowNameRangesRef() { return xRowNameRanges
; }
823 SC_DLLPUBLIC SCCOL
ClampToAllocatedColumns(SCTAB nTab
, SCCOL nCol
) const;
824 SC_DLLPUBLIC SCCOL
GetAllocatedColumnsCount(SCTAB nTab
) const;
826 SC_DLLPUBLIC ScDBCollection
* GetDBCollection() const { return pDBCollection
.get();}
827 void SetDBCollection( std::unique_ptr
<ScDBCollection
> pNewDBCollection
,
828 bool bRemoveAutoFilter
= false );
829 const ScDBData
* GetDBAtCursor(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, ScDBDataPortion ePortion
) const;
830 ScDBData
* GetDBAtCursor(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, ScDBDataPortion ePortion
);
831 SC_DLLPUBLIC
const ScDBData
* GetDBAtArea(SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
) const;
832 SC_DLLPUBLIC ScDBData
* GetDBAtArea(SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
833 void RefreshDirtyTableColumnNames();
834 SC_DLLPUBLIC
sc::ExternalDataMapper
& GetExternalDataMapper();
836 SC_DLLPUBLIC
const ScRangeData
* GetRangeAtBlock( const ScRange
& rBlock
, OUString
& rName
,
837 bool* pSheetLocal
= nullptr ) const;
839 SC_DLLPUBLIC
bool HasPivotTable() const;
840 SC_DLLPUBLIC ScDPCollection
* GetDPCollection();
841 SC_DLLPUBLIC
const ScDPCollection
* GetDPCollection() const;
842 SC_DLLPUBLIC ScDPObject
* GetDPAtCursor(SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
843 SC_DLLPUBLIC ScDPObject
* GetDPAtCursor(ScAddress
const& rAddress
) const
845 return GetDPAtCursor(rAddress
.Col(), rAddress
.Row(), rAddress
.Tab());
847 SC_DLLPUBLIC
bool HasDataPilotAtPosition(ScAddress
const& rAddress
) const
849 return GetDPAtCursor(rAddress
) != nullptr;
851 ScDPObject
* GetDPAtBlock( const ScRange
& rBlock
) const;
853 void StopTemporaryChartLock();
855 void EnsureGraphicNames();
857 SdrObject
* GetObjectAtPoint( SCTAB nTab
, const Point
& rPos
);
858 bool HasChartAtPoint( SCTAB nTab
, const Point
& rPos
, OUString
& rName
);
860 css::uno::Reference
< css::chart2::XChartDocument
> GetChartByName( std::u16string_view rChartName
);
862 SC_DLLPUBLIC
void GetChartRanges( std::u16string_view rChartName
, std::vector
< ScRangeList
>& rRanges
, const ScDocument
& rSheetNameDoc
);
863 void SetChartRanges( std::u16string_view rChartName
, const std::vector
< ScRangeList
>& rRanges
);
865 void UpdateChartArea( const OUString
& rChartName
, const ScRange
& rNewArea
,
866 bool bColHeaders
, bool bRowHeaders
, bool bAdd
);
867 void UpdateChartArea( const OUString
& rChartName
,
868 const ScRangeListRef
& rNewList
,
869 bool bColHeaders
, bool bRowHeaders
, bool bAdd
);
870 void GetOldChartParameters( std::u16string_view rName
,
871 ScRangeList
& rRanges
, bool& rColHeaders
, bool& rRowHeaders
);
873 css::embed::XEmbeddedObject
>
874 FindOleObjectByName( std::u16string_view rName
);
876 SC_DLLPUBLIC
void MakeTable( SCTAB nTab
,bool _bNeedsNameCheck
= true );
878 SCTAB
GetVisibleTab() const { return nVisibleTab
; }
879 SC_DLLPUBLIC
void SetVisibleTab(SCTAB nTab
) { nVisibleTab
= nTab
; }
880 SCCOL
GetPosLeft() const { return nPosLeft
; }
881 SC_DLLPUBLIC
void SetPosLeft(SCCOL nCol
) { nPosLeft
= nCol
; }
882 SCROW
GetPosTop() const { return nPosTop
; }
883 SC_DLLPUBLIC
void SetPosTop(SCROW nRow
) { nPosTop
= nRow
; }
885 SC_DLLPUBLIC
bool HasTable( SCTAB nTab
) const;
886 SC_DLLPUBLIC
bool GetHashCode( SCTAB nTab
, sal_Int64
& rHashCode
) const;
887 SC_DLLPUBLIC
bool GetName( SCTAB nTab
, OUString
& rName
) const;
888 SC_DLLPUBLIC
bool GetCodeName( SCTAB nTab
, OUString
& rName
) const;
889 SC_DLLPUBLIC
bool SetCodeName( SCTAB nTab
, const OUString
& rName
);
890 SC_DLLPUBLIC
bool GetTable( const OUString
& rName
, SCTAB
& rTab
) const;
891 SC_DLLPUBLIC SCCOL
MaxCol() const { return mxSheetLimits
->mnMaxCol
; }
892 SC_DLLPUBLIC SCROW
MaxRow() const { return mxSheetLimits
->mnMaxRow
; }
893 SC_DLLPUBLIC SCCOL
GetMaxColCount() const { return mxSheetLimits
->GetMaxColCount(); }
894 SC_DLLPUBLIC SCROW
GetMaxRowCount() const { return mxSheetLimits
->GetMaxRowCount(); }
895 SC_DLLPUBLIC OUString
MaxRowAsString() const { return mxSheetLimits
->MaxRowAsString(); }
896 SC_DLLPUBLIC OUString
MaxColAsString() const { return mxSheetLimits
->MaxColAsString(); }
897 ScSheetLimits
& GetSheetLimits() const { return *mxSheetLimits
; }
898 [[nodiscard
]] bool ValidCol(SCCOL nCol
) const { return ::ValidCol(nCol
, mxSheetLimits
->mnMaxCol
); }
899 [[nodiscard
]] bool ValidRow(SCROW nRow
) const { return ::ValidRow(nRow
, mxSheetLimits
->mnMaxRow
); }
900 [[nodiscard
]] bool ValidColRow(SCCOL nCol
, SCROW nRow
) const { return ::ValidColRow(nCol
, nRow
, MaxCol(), MaxRow()); }
901 [[nodiscard
]] bool ValidColRowTab(SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const { return ::ValidColRowTab(nCol
, nRow
, nTab
, MaxCol(), MaxRow()); }
902 [[nodiscard
]] bool ValidRange(const ScRange
& rRange
) const { return ::ValidRange(rRange
, MaxCol(), MaxRow()); }
903 [[nodiscard
]] bool ValidAddress(const ScAddress
& rAddress
) const { return ::ValidAddress(rAddress
, MaxCol(), MaxRow()); }
904 [[nodiscard
]] SCCOL
SanitizeCol( SCCOL nCol
) const { return ::SanitizeCol(nCol
, MaxCol()); }
905 [[nodiscard
]] SCROW
SanitizeRow( SCROW nRow
) const { return ::SanitizeRow(nRow
, MaxRow()); }
907 SC_DLLPUBLIC
std::vector
<OUString
> GetAllTableNames() const;
909 OUString
GetCopyTabName(SCTAB nTab
) const;
911 SC_DLLPUBLIC
void SetAnonymousDBData(SCTAB nTab
, std::unique_ptr
<ScDBData
> pDBData
);
912 SC_DLLPUBLIC ScDBData
* GetAnonymousDBData(SCTAB nTab
);
914 /** One document global anonymous database range for temporary operations,
915 used if the corresponding sheet-local anonymous database range is
916 already used with AutoFilter and range differs. Not stored in document
918 SC_DLLPUBLIC
void SetAnonymousDBData(std::unique_ptr
<ScDBData
> pDBData
);
919 SC_DLLPUBLIC ScDBData
* GetAnonymousDBData();
921 SC_DLLPUBLIC SCTAB
GetTableCount() const;
922 SvNumberFormatterIndexTable
* GetFormatExchangeList() const { return pFormatExchangeList
; }
924 SC_DLLPUBLIC ScDocProtection
* GetDocProtection() const;
925 SC_DLLPUBLIC
void SetDocProtection(const ScDocProtection
* pProtect
);
926 SC_DLLPUBLIC
bool IsDocProtected() const;
927 bool IsDocEditable() const;
928 SC_DLLPUBLIC
bool IsTabProtected( SCTAB nTab
) const;
929 SC_DLLPUBLIC
const ScTableProtection
* GetTabProtection(SCTAB nTab
) const;
930 SC_DLLPUBLIC
void SetTabProtection(SCTAB nTab
, const ScTableProtection
* pProtect
);
931 void CopyTabProtection(SCTAB nTabSrc
, SCTAB nTabDest
);
933 void LockTable(SCTAB nTab
);
934 void UnlockTable(SCTAB nTab
);
936 bool IsBlockEditable( SCTAB nTab
, SCCOL nStartCol
, SCROW nStartRow
,
937 SCCOL nEndCol
, SCROW nEndRow
,
938 bool* pOnlyNotBecauseOfMatrix
= nullptr,
939 bool bNoMatrixAtAll
= false ) const;
940 bool IsSelectionEditable( const ScMarkData
& rMark
,
941 bool* pOnlyNotBecauseOfMatrix
= nullptr ) const;
942 bool HasSelectedBlockMatrixFragment( SCCOL nStartCol
, SCROW nStartRow
,
943 SCCOL nEndCol
, SCROW nEndRow
,
944 const ScMarkData
& rMark
) const;
946 bool IsEditActionAllowed( sc::ColRowEditAction eAction
, SCTAB nTab
, SCCOLROW nStart
, SCCOLROW nEnd
) const;
947 bool IsEditActionAllowed( sc::ColRowEditAction eAction
, const ScMarkData
& rMark
, SCCOLROW nStart
, SCCOLROW nEnd
) const;
949 SC_DLLPUBLIC
bool GetMatrixFormulaRange( const ScAddress
& rCellPos
, ScRange
& rMatrix
);
951 bool IsEmbedded() const { return bIsEmbedded
;}
952 void GetEmbedded( ScRange
& rRange
) const;
953 void SetEmbedded( const ScRange
& rRange
);
954 void ResetEmbedded();
955 tools::Rectangle
GetEmbeddedRect() const; // 1/100 mm
956 void SetEmbedded( SCTAB nTab
, const tools::Rectangle
& rRect
); // from VisArea (1/100 mm)
958 static SC_DLLPUBLIC
bool ValidTabName( const OUString
& rName
);
960 SC_DLLPUBLIC
bool ValidNewTabName( const OUString
& rName
) const;
961 SC_DLLPUBLIC
void CreateValidTabName(OUString
& rName
) const;
962 SC_DLLPUBLIC
void CreateValidTabNames(std::vector
<OUString
>& aNames
, SCTAB nCount
) const;
964 void AppendTabOnLoad(const OUString
& rName
);
965 void SetTabNameOnLoad(SCTAB nTab
, const OUString
& rName
);
966 void InvalidateStreamOnSave();
968 SC_DLLPUBLIC
bool InsertTab( SCTAB nPos
, const OUString
& rName
,
969 bool bExternalDocument
= false, bool bUndoDeleteTab
= false );
971 SC_DLLPUBLIC
bool InsertTabs( SCTAB nPos
, const std::vector
<OUString
>& rNames
,
972 bool bNamesValid
= false );
973 SC_DLLPUBLIC
bool DeleteTabs( SCTAB nTab
, SCTAB nSheets
);
974 SC_DLLPUBLIC
bool DeleteTab( SCTAB nTab
);
975 SC_DLLPUBLIC
bool RenameTab( SCTAB nTab
, const OUString
& rName
,
976 bool bExternalDocument
= false );
977 bool MoveTab( SCTAB nOldPos
, SCTAB nNewPos
, ScProgress
* pProgress
= nullptr );
978 SC_DLLPUBLIC
bool CopyTab( SCTAB nOldPos
, SCTAB nNewPos
,
979 const ScMarkData
* pOnlyMarked
= nullptr );
980 SC_DLLPUBLIC sal_uLong
TransferTab(ScDocument
& rSrcDoc
, SCTAB nSrcPos
, SCTAB nDestPos
,
981 bool bInsertNew
= true,
982 bool bResultsOnly
= false );
983 SC_DLLPUBLIC
void TransferDrawPage(const ScDocument
& rSrcDoc
, SCTAB nSrcPos
, SCTAB nDestPos
);
984 SC_DLLPUBLIC
void SetVisible( SCTAB nTab
, bool bVisible
);
985 SC_DLLPUBLIC
bool IsVisible( SCTAB nTab
) const;
986 bool IsStreamValid( SCTAB nTab
) const;
987 void SetStreamValid( SCTAB nTab
, bool bSet
, bool bIgnoreLock
= false );
988 void LockStreamValid( bool bLock
);
989 bool IsStreamValidLocked() const { return mbStreamValidLocked
; }
990 bool IsPendingRowHeights( SCTAB nTab
) const;
991 void SetPendingRowHeights( SCTAB nTab
, bool bSet
);
992 SC_DLLPUBLIC
void SetLayoutRTL( SCTAB nTab
, bool bRTL
, ScObjectHandling eObjectHandling
= ScObjectHandling::RecalcPosMode
);
993 SC_DLLPUBLIC
bool IsLayoutRTL( SCTAB nTab
) const;
994 SC_DLLPUBLIC
bool IsNegativePage( SCTAB nTab
) const;
995 SC_DLLPUBLIC
void SetScenario( SCTAB nTab
, bool bFlag
);
996 SC_DLLPUBLIC
bool IsScenario( SCTAB nTab
) const;
997 SC_DLLPUBLIC
void GetScenarioData(SCTAB nTab
, OUString
& rComment
,
998 Color
& rColor
, ScScenarioFlags
&rFlags
) const;
999 SC_DLLPUBLIC
void SetScenarioData(SCTAB nTab
, const OUString
& rComment
,
1000 const Color
& rColor
, ScScenarioFlags nFlags
);
1001 SC_DLLPUBLIC Color
GetTabBgColor( SCTAB nTab
) const;
1002 SC_DLLPUBLIC
void SetTabBgColor( SCTAB nTab
, const Color
& rColor
);
1003 SC_DLLPUBLIC
bool IsDefaultTabBgColor( SCTAB nTab
) const;
1004 void GetScenarioFlags(SCTAB nTab
, ScScenarioFlags
&rFlags
) const;
1005 SC_DLLPUBLIC
bool IsActiveScenario( SCTAB nTab
) const;
1006 SC_DLLPUBLIC
void SetActiveScenario( SCTAB nTab
, bool bActive
); // only for Undo etc.
1007 SC_DLLPUBLIC
formula::FormulaGrammar::AddressConvention
GetAddressConvention() const;
1008 SC_DLLPUBLIC
formula::FormulaGrammar::Grammar
GetGrammar() const { return eGrammar
;}
1009 SC_DLLPUBLIC
void SetGrammar( formula::FormulaGrammar::Grammar eGram
);
1010 SC_DLLPUBLIC ScLinkMode
GetLinkMode( SCTAB nTab
) const;
1011 bool IsLinked( SCTAB nTab
) const;
1012 SC_DLLPUBLIC OUString
GetLinkDoc( SCTAB nTab
) const;
1013 OUString
GetLinkFlt( SCTAB nTab
) const;
1014 OUString
GetLinkOpt( SCTAB nTab
) const;
1015 SC_DLLPUBLIC OUString
GetLinkTab( SCTAB nTab
) const;
1016 sal_uLong
GetLinkRefreshDelay( SCTAB nTab
) const;
1017 void SetLink( SCTAB nTab
, ScLinkMode nMode
, const OUString
& rDoc
,
1018 const OUString
& rFilter
, const OUString
& rOptions
,
1019 const OUString
& rTabName
, sal_uLong nRefreshDelay
);
1020 bool HasLink( std::u16string_view rDoc
,
1021 std::u16string_view rFilter
, std::u16string_view rOptions
) const;
1022 SC_DLLPUBLIC
bool LinkExternalTab( SCTAB
& nTab
, const OUString
& aDocTab
,
1023 const OUString
& aFileName
,
1024 const OUString
& aTabName
);
1026 bool HasExternalRefManager() const { return bool(pExternalRefMgr
); }
1027 SC_DLLPUBLIC ScExternalRefManager
* GetExternalRefManager() const;
1028 bool IsInExternalReferenceMarking() const;
1029 void MarkUsedExternalReferences();
1030 bool MarkUsedExternalReferences( const ScTokenArray
& rArr
, const ScAddress
& rPos
);
1032 /** Returns the pool containing external formula parsers. Creates the pool
1034 ScFormulaParserPool
& GetFormulaParserPool() const;
1036 bool HasAreaLinks() const;
1037 void UpdateExternalRefLinks(weld::Window
* pWin
);
1038 void UpdateAreaLinks();
1040 // originating DDE links
1041 void IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate
< 255 ) ++nInDdeLinkUpdate
; }
1042 void DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate
) --nInDdeLinkUpdate
; }
1043 bool IsInDdeLinkUpdate() const { return nInDdeLinkUpdate
!= 0; }
1045 SC_DLLPUBLIC
void CopyDdeLinks( ScDocument
& rDestDoc
) const;
1047 /** Tries to find a DDE link with the specified connection data.
1048 @param rnDdePos (out-param) Returns the index of the DDE link (does not include other links from link manager).
1049 @return true = DDE link found, rnDdePos valid. */
1050 SC_DLLPUBLIC
bool FindDdeLink( std::u16string_view rAppl
, std::u16string_view rTopic
,
1051 std::u16string_view rItem
, sal_uInt8 nMode
, size_t& rnDdePos
);
1053 /** Returns the connection data of the specified DDE link.
1054 @param nDdePos Index of the DDE link (does not include other links from link manager).
1055 @param rAppl (out-param) The application name.
1056 @param rTopic (out-param) The DDE topic.
1057 @param rItem (out-param) The DDE item.
1058 @return true = DDE link found, out-parameters valid. */
1059 bool GetDdeLinkData( size_t nDdePos
, OUString
& rAppl
, OUString
& rTopic
, OUString
& rItem
) const;
1060 /** Returns the link mode of the specified DDE link.
1061 @param nDdePos Index of the DDE link (does not include other links from link manager).
1062 @param rnMode (out-param) The link mode of the specified DDE link.
1063 @return true = DDE link found, rnMode valid. */
1064 bool GetDdeLinkMode( size_t nDdePos
, sal_uInt8
& rnMode
) const;
1065 /** Returns the result matrix of the specified DDE link.
1066 @param nDdePos Index of the DDE link (does not include other links from link manager).
1067 @return The result matrix, if the DDE link has been found, 0 otherwise. */
1068 SC_DLLPUBLIC
const ScMatrix
* GetDdeLinkResultMatrix( size_t nDdePos
) const;
1070 /** Tries to find a DDE link or creates a new, if not extant.
1071 @param pResults If not 0, sets the matrix as DDE link result matrix (also for existing links).
1072 @return true = DDE link found; false = Unpredictable error occurred, no DDE link created. */
1073 SC_DLLPUBLIC
bool CreateDdeLink( const OUString
& rAppl
, const OUString
& rTopic
, const OUString
& rItem
, sal_uInt8 nMode
, const ScMatrixRef
& pResults
);
1074 /** Sets a result matrix for the specified DDE link.
1075 @param nDdePos Index of the DDE link (does not include other links from link manager).
1076 @param pResults The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
1077 @return true = DDE link found and matrix set. */
1078 bool SetDdeLinkResultMatrix( size_t nDdePos
, const ScMatrixRef
& pResults
);
1080 SfxBindings
* GetViewBindings();
1081 SfxObjectShell
* GetDocumentShell() const { return mpShell
; }
1082 SC_DLLPUBLIC ScDrawLayer
* GetDrawLayer() { return mpDrawLayer
.get(); }
1083 SC_DLLPUBLIC
const ScDrawLayer
* GetDrawLayer() const { return mpDrawLayer
.get(); }
1084 SfxBroadcaster
* GetDrawBroadcaster(); // to avoid header
1085 void BeginDrawUndo();
1087 void BeginUnoRefUndo();
1088 bool HasUnoRefUndo() const { return ( pUnoRefUndoList
!= nullptr ); }
1090 std::unique_ptr
<ScUnoRefList
> EndUnoRefUndo(); // must be deleted by caller!
1091 sal_Int64
GetNewUnoId() { return ++nUnoObjectId
; }
1092 void AddUnoRefChange( sal_Int64 nId
, const ScRangeList
& rOldRanges
);
1094 static bool IsChart( const SdrObject
* pObject
);
1096 void UpdateChartRef( UpdateRefMode eUpdateRefMode
,
1097 SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
1098 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
,
1099 SCCOL nDx
, SCROW nDy
, SCTAB nDz
);
1100 //! only assigns the new RangeList, no ChartListener or the like
1101 void SetChartRangeList( std::u16string_view rChartName
,
1102 const ScRangeListRef
& rNewRangeListRef
);
1104 void StartAnimations( SCTAB nTab
);
1106 bool HasBackgroundDraw( SCTAB nTab
, const tools::Rectangle
& rMMRect
) const;
1107 bool HasAnyDraw( SCTAB nTab
, const tools::Rectangle
& rMMRect
) const;
1109 const ScSheetEvents
* GetSheetEvents( SCTAB nTab
) const;
1110 void SetSheetEvents( SCTAB nTab
, std::unique_ptr
<ScSheetEvents
> pNew
);
1111 bool HasSheetEventScript( SCTAB nTab
, ScSheetEventId nEvent
, bool bWithVbaEvents
= false ) const;
1112 bool HasAnySheetEventScript( ScSheetEventId nEvent
, bool bWithVbaEvents
= false ) const; // on any sheet
1114 bool HasAnyCalcNotification() const;
1115 bool HasCalcNotification( SCTAB nTab
) const;
1116 void SetCalcNotification( SCTAB nTab
);
1117 void ResetCalcNotifications();
1119 SC_DLLPUBLIC ScOutlineTable
* GetOutlineTable( SCTAB nTab
, bool bCreate
= false );
1120 bool SetOutlineTable( SCTAB nTab
, const ScOutlineTable
* pNewOutline
);
1122 void DoAutoOutline( SCCOL nStartCol
, SCROW nStartRow
,
1123 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
);
1125 bool DoSubTotals( SCTAB nTab
, ScSubTotalParam
& rParam
);
1126 void RemoveSubTotals( SCTAB nTab
, ScSubTotalParam
& rParam
);
1127 bool TestRemoveSubTotals( SCTAB nTab
, const ScSubTotalParam
& rParam
);
1128 bool HasSubTotalCells( const ScRange
& rRange
);
1130 SC_DLLPUBLIC
void EnsureTable( SCTAB nTab
);
1132 // return TRUE = number format is set
1133 SC_DLLPUBLIC
bool SetString( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const OUString
& rString
,
1134 const ScSetStringParam
* pParam
= nullptr );
1135 SC_DLLPUBLIC
bool SetString( const ScAddress
& rPos
, const OUString
& rString
,
1136 const ScSetStringParam
* pParam
= nullptr );
1139 * This method manages the lifecycle of the passed edit text object. When
1140 * the text is successfully inserted, the cell takes over the ownership of
1141 * the text object. If not, the text object gets deleted.
1143 * <p>The caller must ensure that the passed edit text object <i>uses the
1144 * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
1145 * This is very important.</p>
1147 SC_DLLPUBLIC
bool SetEditText( const ScAddress
& rPos
, std::unique_ptr
<EditTextObject
> pEditText
);
1148 void SetEditText( const ScAddress
& rPos
, const EditTextObject
& rEditText
, const SfxItemPool
* pEditPool
);
1149 SC_DLLPUBLIC
void SetEditText( const ScAddress
& rPos
, const OUString
& rStr
);
1150 SC_DLLPUBLIC SCROW
GetFirstEditTextRow( const ScRange
& rRange
) const;
1153 * Call this if you are not sure whether to put this as an edit text or a
1156 SC_DLLPUBLIC
void SetTextCell( const ScAddress
& rPos
, const OUString
& rStr
);
1157 void SetEmptyCell( const ScAddress
& rPos
);
1158 SC_DLLPUBLIC
void SetValue( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const double& rVal
);
1159 SC_DLLPUBLIC
void SetValue( const ScAddress
& rPos
, double fVal
);
1160 void SetValues( const ScAddress
& rPos
, const std::vector
<double>& rVals
);
1161 void SetError( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const FormulaError nError
);
1162 SC_DLLPUBLIC
void SetFormula( const ScAddress
& rPos
, const ScTokenArray
& rArray
);
1163 SC_DLLPUBLIC
void SetFormula( const ScAddress
& rPos
, const OUString
& rFormula
,
1164 formula::FormulaGrammar::Grammar eGram
);
1167 * Set formula cell, and transfer its ownership to the document. This call
1168 * attempts to group the passed formula cell with the adjacent cells or
1169 * cell groups if appropriate.
1171 * @return pCell if it was successfully inserted, NULL otherwise. pCell
1172 * is deleted automatically on failure to insert.
1174 SC_DLLPUBLIC ScFormulaCell
* SetFormulaCell( const ScAddress
& rPos
, ScFormulaCell
* pCell
);
1175 bool SetFormulaCells( const ScAddress
& rPos
, std::vector
<ScFormulaCell
*>& rCells
);
1178 * Check if there is at least one formula cell in specified range.
1180 bool HasFormulaCell( const ScRange
& rRange
) const;
1181 SC_DLLPUBLIC
void InsertMatrixFormula(SCCOL nCol1
, SCROW nRow1
,
1182 SCCOL nCol2
, SCROW nRow2
,
1183 const ScMarkData
& rMark
,
1184 const OUString
& rFormula
,
1185 const ScTokenArray
* p
= nullptr,
1186 const formula::FormulaGrammar::Grammar
= formula::FormulaGrammar::GRAM_DEFAULT
);
1187 SC_DLLPUBLIC
void InsertTableOp(const ScTabOpParam
& rParam
, // multi-operation
1188 SCCOL nCol1
, SCROW nRow1
,
1189 SCCOL nCol2
, SCROW nRow2
, const ScMarkData
& rMark
);
1191 SC_DLLPUBLIC OUString
GetString( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1192 const ScInterpreterContext
* pContext
= nullptr ) const;
1193 SC_DLLPUBLIC OUString
GetString( const ScAddress
& rPos
,
1194 const ScInterpreterContext
* pContext
= nullptr ) const;
1197 * Return a pointer to the double value stored in value cell.
1199 * @param rPos cell position
1201 * @return pointer to the double value stored in a numeric cell, or NULL
1202 * if the cell at specified position is not a numeric cell.
1204 SC_DLLPUBLIC
double* GetValueCell( const ScAddress
& rPos
);
1206 SC_DLLPUBLIC
svl::SharedStringPool
& GetSharedStringPool();
1207 const svl::SharedStringPool
& GetSharedStringPool() const;
1209 svl::SharedString
GetSharedString( const ScAddress
& rPos
) const;
1211 std::shared_ptr
<sc::FormulaGroupContext
>& GetFormulaGroupContext();
1212 void DiscardFormulaGroupContext();
1213 void BlockFormulaGroupContextDiscard( bool block
)
1214 { mbFormulaGroupCxtBlockDiscard
= block
; }
1216 // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
1217 SC_DLLPUBLIC OUString
GetInputString( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, bool bForceSystemLocale
= false ) const;
1218 FormulaError
GetStringForFormula( const ScAddress
& rPos
, OUString
& rString
);
1219 SC_DLLPUBLIC
double GetValue( const ScAddress
& rPos
) const;
1220 SC_DLLPUBLIC
double GetValue( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1221 SC_DLLPUBLIC
const EditTextObject
* GetEditText( const ScAddress
& rPos
) const;
1222 void RemoveEditTextCharAttribs( const ScAddress
& rPos
, const ScPatternAttr
& rAttr
);
1223 SC_DLLPUBLIC
double RoundValueAsShown( double fVal
, sal_uInt32 nFormat
, const ScInterpreterContext
* pContext
= nullptr ) const;
1224 SC_DLLPUBLIC sal_uInt32
GetNumberFormat( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1225 sal_uInt32
GetNumberFormat( const ScRange
& rRange
) const;
1226 SC_DLLPUBLIC sal_uInt32
GetNumberFormat( const ScInterpreterContext
& rContext
, const ScAddress
& ) const;
1227 void SetNumberFormat( const ScAddress
& rPos
, sal_uInt32 nNumberFormat
);
1229 void GetNumberFormatInfo( const ScInterpreterContext
& rContext
, SvNumFormatType
& nType
, sal_uInt32
& nIndex
, const ScAddress
& rPos
) const;
1230 SC_DLLPUBLIC
const ScFormulaCell
* GetFormulaCell( const ScAddress
& rPos
) const;
1231 SC_DLLPUBLIC ScFormulaCell
* GetFormulaCell( const ScAddress
& rPos
);
1232 SC_DLLPUBLIC OUString
GetFormula( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1233 SC_DLLPUBLIC CellType
GetCellType( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1234 SC_DLLPUBLIC CellType
GetCellType( const ScAddress
& rPos
) const;
1236 SC_DLLPUBLIC
bool HasData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1237 SC_DLLPUBLIC
bool HasStringData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1238 SC_DLLPUBLIC
bool HasValueData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1239 SC_DLLPUBLIC
bool HasValueData( const ScAddress
& rPos
) const;
1240 bool HasStringCells( const ScRange
& rRange
) const;
1242 /** Returns true, if there is any data to create a selection list for rPos. */
1243 bool HasSelectionData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1244 bool HasValidationData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1247 * Check if the specified range contains either: 1) one non-empty cell, 2)
1248 * more than one non-empty cells, or 3) totally empty. In case the range
1249 * contains at least one non-empty cell, specify the position of the first
1252 sc::MultiDataCellState
HasMultipleDataCells( const ScRange
& rRange
) const;
1255 /** Returns sparkline at the address if it exists */
1256 SC_DLLPUBLIC
std::shared_ptr
<sc::Sparkline
> GetSparkline(ScAddress
const & rPosition
);
1257 SC_DLLPUBLIC
bool HasSparkline(ScAddress
const & rPosition
);
1258 SC_DLLPUBLIC
sc::Sparkline
* CreateSparkline(ScAddress
const & rPosition
, std::shared_ptr
<sc::SparklineGroup
> const& pSparklineGroup
);
1259 SC_DLLPUBLIC
sc::SparklineList
* GetSparklineList(SCTAB nTab
);
1260 SC_DLLPUBLIC
bool DeleteSparkline(ScAddress
const& rPosition
);
1263 * Returns true if the whole range covers one and the same sparkline
1264 * group and returns the group via out parameter
1266 SC_DLLPUBLIC
bool GetSparklineGroupInRange(ScRange
const& rRange
, std::shared_ptr
<sc::SparklineGroup
>& rGroup
);
1267 SC_DLLPUBLIC
bool HasOneSparklineGroup(ScRange
const& rRange
);
1268 SC_DLLPUBLIC
std::shared_ptr
<sc::SparklineGroup
> SearchSparklineGroup(tools::Guid
const& rGuid
);
1271 SC_DLLPUBLIC ScPostIt
* GetNote(const ScAddress
& rPos
);
1272 SC_DLLPUBLIC ScPostIt
* GetNote(SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1273 void SetNote(const ScAddress
& rPos
, std::unique_ptr
<ScPostIt
> pNote
);
1274 void SetNote(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, std::unique_ptr
<ScPostIt
> pNote
);
1275 SC_DLLPUBLIC
bool HasNote(const ScAddress
& rPos
) const;
1276 bool HasNote(SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1277 bool HasNote(SCTAB nTab
, SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
) const;
1278 SC_DLLPUBLIC
bool HasColNotes(SCCOL nCol
, SCTAB nTab
) const;
1279 SC_DLLPUBLIC
bool HasTabNotes(SCTAB nTab
) const;
1280 bool HasNotes() const;
1281 SC_DLLPUBLIC
std::unique_ptr
<ScPostIt
> ReleaseNote(const ScAddress
& rPos
);
1282 SC_DLLPUBLIC ScPostIt
* GetOrCreateNote(const ScAddress
& rPos
);
1283 SC_DLLPUBLIC ScPostIt
* CreateNote(const ScAddress
& rPos
);
1284 size_t GetNoteCount( SCTAB nTab
, SCCOL nCol
) const;
1287 * Ensure that all note objects have an associated sdr object. The export
1288 * code uses sdr objects to export note data.
1290 void CreateAllNoteCaptions();
1291 void ForgetNoteCaptions( const ScRangeList
& rRanges
, bool bPreserveData
);
1292 CommentCaptionState
GetAllNoteCaptionsState( const ScRangeList
& rRanges
);
1294 ScAddress
GetNotePosition( size_t nIndex
) const;
1295 ScAddress
GetNotePosition( size_t nIndex
, SCTAB nTab
) const;
1296 SCROW
GetNotePosition( SCTAB nTab
, SCCOL nCol
, size_t nIndex
) const;
1298 SC_DLLPUBLIC
void GetAllNoteEntries( std::vector
<sc::NoteEntry
>& rNotes
) const;
1299 SC_DLLPUBLIC
void GetAllNoteEntries( SCTAB nTab
, std::vector
<sc::NoteEntry
>& rNotes
) const;
1300 void GetNotesInRange( const ScRangeList
& rRange
, std::vector
<sc::NoteEntry
>& rNotes
) const;
1302 bool ContainsNotesInRange( const ScRangeList
& rRange
) const;
1304 SC_DLLPUBLIC
void SetDrawPageSize(SCTAB nTab
);
1306 bool IsMerged( const ScAddress
& rPos
) const;
1308 void ExtendMergeSel( SCCOL nStartCol
, SCROW nStartRow
,
1309 SCCOL
& rEndCol
, SCROW
& rEndRow
, const ScMarkData
& rMark
,
1310 bool bRefresh
= false );
1311 SC_DLLPUBLIC
bool ExtendMerge( SCCOL nStartCol
, SCROW nStartRow
,
1312 SCCOL
& rEndCol
, SCROW
& rEndRow
, SCTAB nTab
,
1313 bool bRefresh
= false );
1314 bool ExtendMerge( ScRange
& rRange
, bool bRefresh
= false );
1315 SC_DLLPUBLIC
void ExtendTotalMerge( ScRange
& rRange
) const;
1316 SC_DLLPUBLIC
void ExtendOverlapped( SCCOL
& rStartCol
, SCROW
& rStartRow
,
1317 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
) const;
1318 SC_DLLPUBLIC
void ExtendOverlapped( ScRange
& rRange
) const;
1320 bool RefreshAutoFilter( SCCOL nStartCol
, SCROW nStartRow
,
1321 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
);
1323 SC_DLLPUBLIC
void DoMergeContents( SCCOL nStartCol
, SCROW nStartRow
,
1324 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
);
1325 SC_DLLPUBLIC
void DoEmptyBlock( SCCOL nStartCol
, SCROW nStartRow
,
1326 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
);
1327 // without checking:
1328 SC_DLLPUBLIC
void DoMerge( SCCOL nStartCol
, SCROW nStartRow
,
1329 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
, bool bDeleteCaptions
= true );
1330 void RemoveMerge( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1332 // This also includes e.g. notes. Use IsEmptyData() for cell data only.
1333 bool IsBlockEmpty( SCCOL nStartCol
, SCROW nStartRow
,
1334 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
) const;
1335 bool IsPrintEmpty( SCCOL nStartCol
, SCROW nStartRow
,
1336 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
,
1337 bool bLeftIsEmpty
= false,
1338 ScRange
* pLastRange
= nullptr,
1339 tools::Rectangle
* pLastMM
= nullptr ) const;
1341 void SkipOverlapped( SCCOL
& rCol
, SCROW
& rRow
, SCTAB nTab
) const;
1342 bool IsHorOverlapped( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1343 bool IsVerOverlapped( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1344 SCROW
* nStartRow
= nullptr, SCROW
* nEndRow
= nullptr ) const;
1346 SC_DLLPUBLIC
bool HasAttrib( SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
1347 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
, HasAttrFlags nMask
) const;
1348 SC_DLLPUBLIC
bool HasAttrib( const ScRange
& rRange
, HasAttrFlags nMask
) const;
1349 bool HasAttrib( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, HasAttrFlags nMask
,
1350 SCROW
* nStartRow
= nullptr, SCROW
* nEndRow
= nullptr ) const;
1352 SC_DLLPUBLIC
void GetBorderLines( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1353 const ::editeng::SvxBorderLine
** ppLeft
,
1354 const ::editeng::SvxBorderLine
** ppTop
,
1355 const ::editeng::SvxBorderLine
** ppRight
,
1356 const ::editeng::SvxBorderLine
** ppBottom
) const;
1358 void ResetChanged( const ScRange
& rRange
);
1360 void CheckVectorizationState();
1361 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext
& rCxt
);
1362 void SetDirty( const ScRange
&, bool bIncludeEmptyCells
);
1363 void SetTableOpDirty( const ScRange
& ); // for Interpreter TableOp
1364 void InterpretDirtyCells( const ScRangeList
& rRanges
);
1365 // Interprets cells that have NeedsInterpret(), i.e. the same like calling MaybeInterpret() on them.
1366 // Returns false if some couldn't be interpreted (i.e. they still have NeedsInterpret()).
1367 // Useful to ensure that the given cells will not need interpreting.
1368 bool InterpretCellsIfNeeded( const ScRangeList
& rRanges
);
1369 SC_DLLPUBLIC
void CalcAll();
1370 SC_DLLPUBLIC
void CalcAfterLoad( bool bStartListening
= true );
1375 * Re-compile formula cells with error.
1377 * @param nErrCode specified error code to match. Only those cells with
1378 * this error code will be re-compiled. If this value is
1379 * 0, cells with any error values will be re-compiled.
1381 * @return true if at least one cell is re-compiled, false if no cells are
1384 bool CompileErrorCells(FormulaError nErrCode
);
1386 ScAutoNameCache
* GetAutoNameCache() { return pAutoNameCache
.get(); }
1387 void SetPreviewFont( std::unique_ptr
<SfxItemSet
> pFontSet
);
1388 SfxItemSet
* GetPreviewFont() { return pPreviewFont
.get(); }
1389 SfxItemSet
* GetPreviewFont( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1390 const ScMarkData
& GetPreviewSelection() const { return maPreviewSelection
; }
1391 void SetPreviewSelection( const ScMarkData
& rSel
);
1392 ScStyleSheet
* GetPreviewCellStyle() { return pPreviewCellStyle
; }
1393 ScStyleSheet
* GetPreviewCellStyle( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1394 void SetPreviewCellStyle( ScStyleSheet
* pStyle
) { pPreviewCellStyle
= pStyle
; }
1395 SC_DLLPUBLIC
void SetAutoNameCache( std::unique_ptr
<ScAutoNameCache
> pCache
);
1397 /** Creates a ScLookupCache cache for the range if it
1398 doesn't already exist. */
1399 ScLookupCache
& GetLookupCache( const ScRange
& rRange
, ScInterpreterContext
* pContext
);
1400 ScSortedRangeCache
& GetSortedRangeCache( const ScRange
& rRange
, const ScQueryParam
& param
,
1401 ScInterpreterContext
* pContext
);
1402 /** Only ScLookupCache dtor uses RemoveLookupCache(), do
1403 not use elsewhere! */
1404 void RemoveLookupCache( ScLookupCache
& rCache
);
1405 void RemoveSortedRangeCache( ScSortedRangeCache
& rCache
);
1406 /** Zap all caches. */
1407 void ClearLookupCaches();
1409 // calculate automatically
1410 SC_DLLPUBLIC
void SetAutoCalc( bool bNewAutoCalc
);
1411 SC_DLLPUBLIC
bool GetAutoCalc() const { return bAutoCalc
; }
1412 // calculate automatically in/from/for ScDocShell disabled
1413 void SetAutoCalcShellDisabled( bool bNew
) { bAutoCalcShellDisabled
= bNew
; }
1414 bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled
; }
1415 // ForcedFormulas are to be calculated
1416 void SetForcedFormulaPending( bool bNew
) { bForcedFormulaPending
= bNew
; }
1417 bool IsForcedFormulaPending() const { return bForcedFormulaPending
; }
1418 // if CalcFormulaTree() is currently running
1419 bool IsCalculatingFormulaTree() const { return bCalculatingFormulaTree
; }
1420 /// If set, joining cells into shared formula groups will be delayed until reset again
1421 /// (RegroupFormulaCells() will be called as needed).
1422 void DelayFormulaGrouping( bool delay
);
1423 bool IsDelayedFormulaGrouping() const { return bool(pDelayedFormulaGrouping
); }
1424 /// To be used only by SharedFormulaUtil::joinFormulaCells().
1425 void AddDelayedFormulaGroupingCell( const ScFormulaCell
* cell
);
1426 /// If set, ScColumn::StartListeningFormulaCells() calls may be delayed using
1427 /// CanDelayStartListeningFormulaCells() until reset again, at which point the function will
1428 /// be called as necessary.
1429 void EnableDelayStartListeningFormulaCells( ScColumn
* column
, bool delay
);
1430 bool IsEnabledDelayStartListeningFormulaCells( ScColumn
* column
) const;
1431 /// If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed
1432 /// later. If false is returned, it needs to be done explicitly.
1433 bool CanDelayStartListeningFormulaCells( ScColumn
* column
, SCROW row1
, SCROW row2
);
1434 /// If set, cells will not delete their empty broadcasters, avoiding possible extensive mdds
1435 /// vector changes. Disabling delay will collect and delete all empty broadcasters.
1436 void EnableDelayDeletingBroadcasters(bool set
);
1437 bool IsDelayedDeletingBroadcasters() const { return bDelayedDeletingBroadcasters
; }
1439 FormulaError
GetErrCode( const ScAddress
& ) const;
1441 /** Shrink a range to only include data area.
1443 This is not the actually used area within the
1444 selection, but the bounds of the sheet's data area
1447 @returns TRUE if the area passed intersected the data
1448 area, FALSE if not, in which case the values
1449 obtained may be out of bounds, not in order or
1450 unmodified. TRUE does not mean that there
1451 actually is any data within the selection.
1453 bool ShrinkToDataArea( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
, SCCOL
& rEndCol
, SCROW
& rEndRow
) const;
1455 /** Shrink a range to only include used data area.
1458 Out parameter, true if area was shrunk, false if not.
1460 If TRUE, shrink only by columns, not rows.
1461 @param bStickyTopRow
1462 If TRUE, do not adjust the top row.
1463 @param bStickyLeftCol
1464 If TRUE, do not adjust the left column.
1465 @param pDataAreaExtras
1466 Consider additional area attributes like cell
1467 formatting, cell notes and draw objects. The
1468 possibly larger area than the actual cell
1469 content data area is returned within the
1472 @returns true if there is any data, false if not.
1474 bool ShrinkToUsedDataArea( bool& o_bShrunk
,
1475 SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
,
1476 SCCOL
& rEndCol
, SCROW
& rEndRow
, bool bColumnsOnly
,
1477 bool bStickyTopRow
= false, bool bStickyLeftCol
= false,
1478 ScDataAreaExtras
* pDataAreaExtras
= nullptr ) const;
1481 * Return the last non-empty row position in given columns that's no
1482 * greater than the initial last row position, or 0 if the columns are
1483 * empty. A negative value is returned if the given sheet or column
1484 * positions are invalid.
1486 * <p>It starts from the specified last row position, and finds the first
1487 * non-empty row position in the upward direction if the start row
1488 * position is empty.</p>
1490 SC_DLLPUBLIC SCROW
GetLastDataRow( SCTAB nTab
, SCCOL nCol1
, SCCOL nCol2
, SCROW nLastRow
) const;
1493 * Return the smallest area containing at least all contiguous cells
1494 * having data. This area is a square containing also empty cells. It may
1495 * shrink or extend the area given as input Flags as modifiers:
1497 * @param bIncludeOld when true, ensure that the returned area contains at
1498 * least the initial area even if the actual data area
1499 * is smaller than the initial area.
1501 * @param bOnlyDown when true, extend / shrink the data area only in a
1502 * downward direction i.e. only modify the end row
1505 SC_DLLPUBLIC
void GetDataArea( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
,
1506 SCCOL
& rEndCol
, SCROW
& rEndRow
,
1507 bool bIncludeOld
, bool bOnlyDown
) const;
1510 * Returns true if there is a non-empty subrange in the range given as input.
1511 * In that case it also modifies rRange to largest subrange that does not
1512 * have empty col/row inrange-segments in the beginning/end.
1513 * It returns false if rRange is completely empty and in this case rRange is
1516 bool GetDataAreaSubrange(ScRange
& rRange
) const;
1518 SC_DLLPUBLIC
bool GetCellArea( SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
) const;
1519 SC_DLLPUBLIC
bool GetTableArea( SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
,
1520 bool bCalcHiddens
= false) const;
1521 SC_DLLPUBLIC
bool GetPrintArea( SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
,
1522 bool bNotes
= true) const;
1523 SC_DLLPUBLIC
bool GetPrintAreaHor( SCTAB nTab
, SCROW nStartRow
, SCROW nEndRow
,
1524 SCCOL
& rEndCol
) const;
1525 SC_DLLPUBLIC
bool GetPrintAreaVer( SCTAB nTab
, SCCOL nStartCol
, SCCOL nEndCol
,
1526 SCROW
& rEndRow
, bool bNotes
) const;
1527 void InvalidateTableArea();
1529 /// Return the number of columns / rows that should be visible for the tiled rendering.
1530 SC_DLLPUBLIC
void GetTiledRenderingArea(SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
) const;
1532 SC_DLLPUBLIC
bool GetDataStart( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
) const;
1535 * Find the maximum column position that contains printable data for the
1536 * specified row range. The final column position must be equal or less
1537 * than the initial value of rEndCol.
1539 void ExtendPrintArea( OutputDevice
* pDev
, SCTAB nTab
,
1540 SCCOL nStartCol
, SCROW nStartRow
,
1541 SCCOL
& rEndCol
, SCROW nEndRow
) const;
1542 SC_DLLPUBLIC
bool IsEmptyData(SCCOL nStartCol
, SCROW nStartRow
,
1543 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
) const;
1544 // I think this returns the number of empty cells starting from the given direction.
1545 SC_DLLPUBLIC SCSIZE
GetEmptyLinesInBlock( SCCOL nStartCol
, SCROW nStartRow
, SCTAB nStartTab
,
1546 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nEndTab
,
1549 void FindAreaPos( SCCOL
& rCol
, SCROW
& rRow
, SCTAB nTab
, ScMoveDirection eDirection
) const;
1550 SC_DLLPUBLIC
void GetNextPos( SCCOL
& rCol
, SCROW
& rRow
, SCTAB nTab
, SCCOL nMovX
, SCROW nMovY
,
1551 bool bMarked
, bool bUnprotected
, const ScMarkData
& rMark
,
1552 SCCOL nTabStartCol
= SC_TABSTART_NONE
) const;
1554 bool GetNextMarkedCell( SCCOL
& rCol
, SCROW
& rRow
, SCTAB nTab
,
1555 const ScMarkData
& rMark
);
1557 void LimitChartArea( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
,
1558 SCCOL
& rEndCol
, SCROW
& rEndRow
);
1559 void LimitChartIfAll( ScRangeListRef
& rRangeList
);
1561 bool InsertRow( SCCOL nStartCol
, SCTAB nStartTab
,
1562 SCCOL nEndCol
, SCTAB nEndTab
,
1563 SCROW nStartRow
, SCSIZE nSize
, ScDocument
* pRefUndoDoc
= nullptr,
1564 const ScMarkData
* pTabMark
= nullptr );
1565 SC_DLLPUBLIC
bool InsertRow( const ScRange
& rRange
);
1566 void DeleteRow( SCCOL nStartCol
, SCTAB nStartTab
,
1567 SCCOL nEndCol
, SCTAB nEndTab
,
1568 SCROW nStartRow
, SCSIZE nSize
,
1569 ScDocument
* pRefUndoDoc
= nullptr, bool* pUndoOutline
= nullptr,
1570 const ScMarkData
* pTabMark
= nullptr );
1571 SC_DLLPUBLIC
void DeleteRow( const ScRange
& rRange
);
1572 bool InsertCol( SCROW nStartRow
, SCTAB nStartTab
,
1573 SCROW nEndRow
, SCTAB nEndTab
,
1574 SCCOL nStartCol
, SCSIZE nSize
, ScDocument
* pRefUndoDoc
= nullptr,
1575 const ScMarkData
* pTabMark
= nullptr );
1576 SC_DLLPUBLIC
bool InsertCol( const ScRange
& rRange
);
1577 void DeleteCol( SCROW nStartRow
, SCTAB nStartTab
,
1578 SCROW nEndRow
, SCTAB nEndTab
,
1579 SCCOL nStartCol
, SCSIZE nSize
,
1580 ScDocument
* pRefUndoDoc
= nullptr, bool* pUndoOutline
= nullptr,
1581 const ScMarkData
* pTabMark
= nullptr );
1582 void DeleteCol( const ScRange
& rRange
);
1584 bool CanInsertRow( const ScRange
& rRange
) const;
1585 bool CanInsertCol( const ScRange
& rRange
) const;
1587 void FitBlock( const ScRange
& rOld
, const ScRange
& rNew
, bool bClear
= true );
1588 bool CanFitBlock( const ScRange
& rOld
, const ScRange
& rNew
);
1590 bool IsClipOrUndo() const { return bIsClip
|| bIsUndo
; }
1591 bool IsUndo() const { return bIsUndo
; }
1592 bool IsClipboard() const { return bIsClip
; }
1593 bool IsUndoEnabled() const { return mbUndoEnabled
; }
1594 SC_DLLPUBLIC
void EnableUndo( bool bVal
);
1595 bool IsFunctionAccess() const { return bIsFunctionAccess
; }
1597 bool IsAdjustHeightLocked() const { return nAdjustHeightLock
!= 0; }
1598 void LockAdjustHeight() { ++nAdjustHeightLock
; }
1599 SC_DLLPUBLIC
void UnlockAdjustHeight();
1600 bool IsExecuteLinkEnabled() const { return mbExecuteLinkEnabled
; }
1601 void EnableExecuteLink( bool bVal
) { mbExecuteLinkEnabled
= bVal
; }
1602 bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled
; }
1603 void EnableChangeReadOnly( bool bVal
) { mbChangeReadOnlyEnabled
= bVal
; }
1604 SC_DLLPUBLIC
bool IsUserInteractionEnabled() const { return mbUserInteractionEnabled
;}
1605 SC_DLLPUBLIC
void EnableUserInteraction( bool bVal
);
1606 SC_DLLPUBLIC sal_Int16
GetNamedRangesLockCount() const { return mnNamedRangesLockCount
; }
1607 void SetNamedRangesLockCount( sal_Int16 nCount
) { mnNamedRangesLockCount
= nCount
; }
1608 SC_DLLPUBLIC
void ResetClip( ScDocument
* pSourceDoc
, const ScMarkData
* pMarks
);
1609 SC_DLLPUBLIC
void ResetClip( ScDocument
* pSourceDoc
, SCTAB nTab
);
1610 void SetCutMode( bool bCut
);
1612 void SetClipArea( const ScRange
& rArea
, bool bCut
= false );
1614 SC_DLLPUBLIC
bool IsDocVisible() const { return bIsVisible
; }
1615 SC_DLLPUBLIC
void SetDocVisible( bool bSet
);
1617 bool HasOLEObjectsInArea( const ScRange
& rRange
, const ScMarkData
* pTabMark
= nullptr );
1619 void DeleteObjectsInArea( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1620 const ScMarkData
& rMark
, bool bAnchored
= false );
1621 void DeleteObjectsInSelection( const ScMarkData
& rMark
);
1623 SC_DLLPUBLIC
void DeleteArea( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
, const ScMarkData
& rMark
,
1624 InsertDeleteFlags nDelFlag
, bool bBroadcast
= true,
1625 sc::ColumnSpanSet
* pBroadcastSpans
= nullptr );
1627 SC_DLLPUBLIC
void DeleteAreaTab(SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1628 SCTAB nTab
, InsertDeleteFlags nDelFlag
);
1629 void DeleteAreaTab(const ScRange
& rRange
, InsertDeleteFlags nDelFlag
);
1631 SC_DLLPUBLIC
void CopyToClip( const ScClipParam
& rClipParam
, ScDocument
* pClipDoc
,
1632 const ScMarkData
* pMarks
, bool bKeepScenarioFlags
,
1633 bool bIncludeObjects
);
1636 * Copy only raw cell values to another document. Formula cells are
1637 * converted to raw cells. No formatting info are copied except for
1640 * @param rSrcRange source range in the source document
1641 * @param nDestTab table in the clip document to copy to.
1642 * @param rDestDoc document to copy to
1644 SC_DLLPUBLIC
void CopyStaticToDocument(const ScRange
& rSrcRange
, SCTAB nDestTab
, ScDocument
& rDestDoc
);
1647 * Copy only cell, nothing but cell to another document.
1649 * @param rSrcPos source cell position
1650 * @param rDestPos destination cell position
1651 * @param rDestDoc destination document
1653 void CopyCellToDocument( const ScAddress
& rSrcPos
, const ScAddress
& rDestPos
, ScDocument
& rDestDoc
);
1655 void CopyTabToClip( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1656 SCTAB nTab
, ScDocument
* pClipDoc
);
1658 SC_DLLPUBLIC
bool InitColumnBlockPosition( sc::ColumnBlockPosition
& rBlockPos
, SCTAB nTab
, SCCOL nCol
);
1660 void DeleteBeforeCopyFromClip( sc::CopyFromClipContext
& rCxt
, const ScMarkData
& rMark
,
1661 sc::ColumnSpanSet
& rBroadcastSpans
);
1663 SC_DLLPUBLIC
bool CopyOneCellFromClip(sc::CopyFromClipContext
& rCxt
, SCCOL nCol1
, SCROW nRow1
,
1664 SCCOL nCol2
, SCROW nRow2
);
1665 void CopyBlockFromClip( sc::CopyFromClipContext
& rCxt
, SCCOL nCol1
, SCROW nRow1
,
1666 SCCOL nCol2
, SCROW nRow2
, const ScMarkData
& rMark
,
1667 SCCOL nDx
, SCROW nDy
);
1669 * @return the number of non-filtered rows.
1671 SCROW
CopyNonFilteredFromClip(sc::CopyFromClipContext
& rCxt
, SCCOL nCol1
, SCROW nRow1
,
1672 SCCOL nCol2
, SCROW nRow2
, const ScMarkData
& rMark
, SCCOL nDx
,
1673 SCROW
& rClipStartRow
, SCROW nClipEndRow
);
1675 void StartListeningFromClip( SCCOL nCol1
, SCROW nRow1
,
1676 SCCOL nCol2
, SCROW nRow2
,
1677 const ScMarkData
& rMark
, InsertDeleteFlags nInsFlag
);
1679 void SetDirtyFromClip( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1680 const ScMarkData
& rMark
, InsertDeleteFlags nInsFlag
,
1681 sc::ColumnSpanSet
& rBroadcastSpans
);
1684 * Paste data from a clipboard document into this document.
1686 * @param rDestRange destination range.
1687 * @param pClipDoc pointer to the clipboard document to copy data from.
1688 * @param bSkipEmptyCells if this flag is set, empty cells in the source
1689 * range in the clipboard document will not overwrite
1690 * the target destination cells.
1691 * @param pDestRanges If pDestRanges is given it overrides rDestRange, where
1692 * rDestRange becomes the overall encompassing range.
1694 SC_DLLPUBLIC
void CopyFromClip(
1695 const ScRange
& rDestRange
, const ScMarkData
& rMark
, InsertDeleteFlags nInsFlag
,
1696 ScDocument
* pRefUndoDoc
, ScDocument
* pClipDoc
,
1697 bool bResetCut
= true, bool bAsLink
= false,
1698 bool bIncludeFiltered
= true, bool bSkipEmptyCells
= false,
1699 const ScRangeList
* pDestRanges
= nullptr );
1701 void CopyMultiRangeFromClip(const ScAddress
& rDestPos
, const ScMarkData
& rMark
,
1702 InsertDeleteFlags nInsFlag
, ScDocument
* pClipDoc
,
1703 bool bResetCut
= true, bool bAsLink
= false,
1704 bool bIncludeFiltered
= true,
1705 bool bSkipAttrForEmpty
= false);
1707 void GetClipArea(SCCOL
& nClipX
, SCROW
& nClipY
, bool bIncludeFiltered
);
1708 void GetClipStart(SCCOL
& nClipX
, SCROW
& nClipY
);
1710 bool HasClipFilteredRows();
1712 bool IsClipboardSource() const;
1714 SC_DLLPUBLIC
void TransposeClip(ScDocument
* pTransClip
, InsertDeleteFlags nFlags
, bool bAsLink
,
1715 bool bIncludeFiltered
);
1717 ScClipParam
& GetClipParam();
1718 void SetClipParam(const ScClipParam
& rParam
);
1720 /** To be called at the clipboard document when closing a document that is
1721 the current clipboard source to decouple things from the originating
1722 document. Done in ScDocument dtor after determining
1723 IsClipboardSource().
1725 void ClosingClipboardSource();
1727 void MixDocument( const ScRange
& rRange
, ScPasteFunc nFunction
, bool bSkipEmpty
,
1728 ScDocument
& rSrcDoc
);
1730 void FillTab( const ScRange
& rSrcArea
, const ScMarkData
& rMark
,
1731 InsertDeleteFlags nFlags
, ScPasteFunc nFunction
,
1732 bool bSkipEmpty
, bool bAsLink
);
1733 void FillTabMarked( SCTAB nSrcTab
, const ScMarkData
& rMark
,
1734 InsertDeleteFlags nFlags
, ScPasteFunc nFunction
,
1735 bool bSkipEmpty
, bool bAsLink
);
1737 void TransliterateText( const ScMarkData
& rMultiMark
, TransliterationFlags nType
);
1739 SC_DLLPUBLIC
void InitUndo( const ScDocument
& rSrcDoc
, SCTAB nTab1
, SCTAB nTab2
,
1740 bool bColInfo
= false, bool bRowInfo
= false );
1741 void AddUndoTab( SCTAB nTab1
, SCTAB nTab2
,
1742 bool bColInfo
= false, bool bRowInfo
= false );
1743 SC_DLLPUBLIC
void InitUndoSelected( const ScDocument
& rSrcDoc
, const ScMarkData
& rTabSelection
,
1744 bool bColInfo
= false, bool bRowInfo
= false );
1746 // don't use anymore:
1747 void CopyToDocument(SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
1748 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
,
1749 InsertDeleteFlags nFlags
, bool bMarked
, ScDocument
& rDestDoc
,
1750 const ScMarkData
* pMarks
= nullptr, bool bColRowFlags
= true);
1751 void UndoToDocument(SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
1752 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
,
1753 InsertDeleteFlags nFlags
, bool bMarked
, ScDocument
& rDestDoc
);
1755 SC_DLLPUBLIC
void CopyToDocument(const ScRange
& rRange
,
1756 InsertDeleteFlags nFlags
, bool bMarked
, ScDocument
& rDestDoc
,
1757 const ScMarkData
* pMarks
= nullptr, bool bColRowFlags
= true);
1758 void UndoToDocument(const ScRange
& rRange
,
1759 InsertDeleteFlags nFlags
, bool bMarked
, ScDocument
& rDestDoc
);
1761 void CopyScenario( SCTAB nSrcTab
, SCTAB nDestTab
, bool bNewScenario
= false );
1762 bool TestCopyScenario( SCTAB nSrcTab
, SCTAB nDestTab
) const;
1763 void MarkScenario(SCTAB nSrcTab
, SCTAB nDestTab
,
1764 ScMarkData
& rDestMark
, bool bResetMark
= true,
1765 ScScenarioFlags nNeededBits
= ScScenarioFlags::NONE
) const;
1766 bool HasScenarioRange( SCTAB nTab
, const ScRange
& rRange
) const;
1767 SC_DLLPUBLIC
const ScRangeList
* GetScenarioRanges( SCTAB nTab
) const;
1769 SC_DLLPUBLIC
void CopyUpdated( ScDocument
* pPosDoc
, ScDocument
* pDestDoc
);
1771 void UpdateReference( sc::RefUpdateContext
& rCxt
, ScDocument
*
1772 pUndoDoc
= nullptr, bool bIncludeDraw
= true,
1773 bool bUpdateNoteCaptionPos
= true );
1775 * @param pClipDoc original clipboard doc, i.e. non-transposed
1776 * This clip doc is used to check references pointing to cut cells.
1778 SC_DLLPUBLIC
void UpdateTranspose( const ScAddress
& rDestPos
, ScDocument
* pClipDoc
,
1779 const ScMarkData
& rMark
, ScDocument
* pUndoDoc
);
1781 void UpdateGrow( const ScRange
& rArea
, SCCOL nGrowX
, SCROW nGrowY
);
1783 SC_DLLPUBLIC
void Fill( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1784 ScProgress
* pProgress
, const ScMarkData
& rMark
,
1785 sal_uInt64 nFillCount
, FillDir eFillDir
= FILL_TO_BOTTOM
,
1786 FillCmd eFillCmd
= FILL_LINEAR
, FillDateCmd eFillDateCmd
= FILL_DAY
,
1787 double nStepValue
= 1.0, double nMaxValue
= 1E307
);
1788 OUString
GetAutoFillPreview( const ScRange
& rSource
, SCCOL nEndX
, SCROW nEndY
);
1790 bool GetSelectionFunction( ScSubTotalFunc eFunc
,
1791 const ScAddress
& rCursor
, const ScMarkData
& rMark
,
1794 SC_DLLPUBLIC
const SfxPoolItem
* GetAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt16 nWhich
) const;
1795 template<class T
> const T
* GetAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, TypedWhichId
<T
> nWhich
) const
1797 return static_cast<const T
*>(GetAttr(nCol
, nRow
, nTab
, sal_uInt16(nWhich
)));
1799 SC_DLLPUBLIC
const SfxPoolItem
* GetAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt16 nWhich
,
1800 SCROW
& nStartRow
, SCROW
& nEndRow
) const;
1801 template<class T
> const T
* GetAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, TypedWhichId
<T
> nWhich
,
1802 SCROW
& nStartRow
, SCROW
& nEndRow
) const
1804 return static_cast<const T
*>(GetAttr(nCol
, nRow
, nTab
, sal_uInt16(nWhich
), nStartRow
, nEndRow
));
1806 SC_DLLPUBLIC
const SfxPoolItem
* GetAttr( const ScAddress
& rPos
, sal_uInt16 nWhich
) const;
1807 template<class T
> const T
* GetAttr( const ScAddress
& rPos
, TypedWhichId
<T
> nWhich
) const
1809 return static_cast<const T
*>(GetAttr(rPos
, sal_uInt16(nWhich
)));
1811 SC_DLLPUBLIC
const ScPatternAttr
* GetPattern( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1812 SC_DLLPUBLIC
const ScPatternAttr
* GetPattern( const ScAddress
& rPos
) const;
1813 SC_DLLPUBLIC
const ScPatternAttr
* GetMostUsedPattern( SCCOL nCol
, SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
1814 const ScPatternAttr
* GetSelectionPattern( const ScMarkData
& rMark
);
1815 std::unique_ptr
<ScPatternAttr
> CreateSelectionPattern( const ScMarkData
& rMark
, bool bDeep
= true );
1816 SC_DLLPUBLIC
void AddCondFormatData( const ScRangeList
& rRange
, SCTAB nTab
, sal_uInt32 nIndex
);
1817 void RemoveCondFormatData( const ScRangeList
& rRange
, SCTAB nTab
, sal_uInt32 nIndex
);
1819 SC_DLLPUBLIC ScConditionalFormat
* GetCondFormat( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1820 // pCell is an optimization, must point to rPos
1821 SC_DLLPUBLIC
const SfxItemSet
* GetCondResult( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1822 ScRefCellValue
* pCell
= nullptr ) const;
1823 const SfxItemSet
* GetCondResult( ScRefCellValue
& rCell
, const ScAddress
& rPos
,
1824 const ScConditionalFormatList
& rList
,
1825 const ScCondFormatIndexes
& rIndex
) const;
1826 const SfxPoolItem
* GetEffItem( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt16 nWhich
) const;
1827 template<class T
> const T
* GetEffItem( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, TypedWhichId
<T
> nWhich
) const
1829 return static_cast<const T
*>(GetEffItem(nCol
, nRow
, nTab
, sal_uInt16(nWhich
)));
1832 SC_DLLPUBLIC
const css::uno::Reference
< css::i18n::XBreakIterator
>& GetBreakIterator();
1833 bool HasStringWeakCharacters( const OUString
& rString
);
1834 SC_DLLPUBLIC SvtScriptType
GetStringScriptType( const OUString
& rString
);
1835 // pCell is an optimization, must point to rPos
1836 SC_DLLPUBLIC SvtScriptType
GetCellScriptType( const ScAddress
& rPos
, sal_uInt32 nNumberFormat
,
1837 const ScRefCellValue
* pCell
= nullptr );
1838 // pCell is an optimization, must point to nCol,nRow,nTab
1839 SC_DLLPUBLIC SvtScriptType
GetScriptType( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1840 const ScRefCellValue
* pCell
= nullptr );
1841 SvtScriptType
GetRangeScriptType( sc::ColumnBlockPosition
& rBlockPos
, const ScAddress
& rPos
, SCROW nLength
);
1842 SvtScriptType
GetRangeScriptType( const ScRangeList
& rRanges
);
1844 bool HasDetectiveOperations() const;
1845 void AddDetectiveOperation( const ScDetOpData
& rData
);
1846 void ClearDetectiveOperations();
1847 ScDetOpList
* GetDetOpList() const { return pDetOpList
.get(); }
1848 void SetDetOpList(std::unique_ptr
<ScDetOpList
> pNew
);
1850 bool HasDetectiveObjects(SCTAB nTab
) const;
1852 void GetSelectionFrame( const ScMarkData
& rMark
,
1853 SvxBoxItem
& rLineOuter
,
1854 SvxBoxInfoItem
& rLineInner
);
1855 void ApplySelectionFrame(const ScMarkData
& rMark
,
1856 const SvxBoxItem
& rLineOuter
,
1857 const SvxBoxInfoItem
* pLineInner
);
1858 void ApplyFrameAreaTab(const ScRange
& rRange
,
1859 const SvxBoxItem
& rLineOuter
,
1860 const SvxBoxInfoItem
& rLineInner
);
1862 void ClearSelectionItems( const sal_uInt16
* pWhich
, const ScMarkData
& rMark
);
1863 void ChangeSelectionIndent( bool bIncrement
, const ScMarkData
& rMark
);
1865 SC_DLLPUBLIC sal_uLong
AddCondFormat( std::unique_ptr
<ScConditionalFormat
> pNew
, SCTAB nTab
);
1866 void DeleteConditionalFormat( sal_uLong nIndex
, SCTAB nTab
);
1868 void SetCondFormList( ScConditionalFormatList
* pList
, SCTAB nTab
);
1869 SC_DLLPUBLIC sal_uLong
AddValidationEntry( const ScValidationData
& rNew
);
1870 SC_DLLPUBLIC
const ScValidationData
* GetValidationEntry( sal_uInt32 nIndex
) const;
1872 SC_DLLPUBLIC ScConditionalFormatList
* GetCondFormList( SCTAB nTab
) const;
1874 const ScValidationDataList
* GetValidationList() const { return pValidationList
.get();}
1875 ScValidationDataList
* GetValidationList() { return pValidationList
.get();}
1877 SC_DLLPUBLIC
void ApplyAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1878 const SfxPoolItem
& rAttr
);
1879 SC_DLLPUBLIC
void ApplyPattern( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1880 const ScPatternAttr
& rAttr
);
1881 SC_DLLPUBLIC
void ApplyPatternArea( SCCOL nStartCol
, SCROW nStartRow
,
1882 SCCOL nEndCol
, SCROW nEndRow
,
1883 const ScMarkData
& rMark
, const ScPatternAttr
& rAttr
,
1884 ScEditDataArray
* pDataArray
= nullptr,
1885 bool* const pIsChanged
= nullptr );
1886 SC_DLLPUBLIC
void ApplyPatternAreaTab( SCCOL nStartCol
, SCROW nStartRow
,
1887 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
,
1888 const ScPatternAttr
& rAttr
);
1890 SC_DLLPUBLIC
void ApplyPatternIfNumberformatIncompatible( const ScRange
& rRange
,
1891 const ScMarkData
& rMark
,
1892 const ScPatternAttr
& rPattern
,
1893 SvNumFormatType nNewType
);
1895 void ApplyStyle( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1896 const ScStyleSheet
& rStyle
);
1897 void ApplyStyleArea( SCCOL nStartCol
, SCROW nStartRow
,
1898 SCCOL nEndCol
, SCROW nEndRow
,
1899 const ScMarkData
& rMark
, const ScStyleSheet
& rStyle
);
1900 SC_DLLPUBLIC
void ApplyStyleAreaTab( SCCOL nStartCol
, SCROW nStartRow
,
1901 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
,
1902 const ScStyleSheet
& rStyle
);
1904 SC_DLLPUBLIC
void ApplySelectionStyle( const ScStyleSheet
& rStyle
, const ScMarkData
& rMark
);
1905 void ApplySelectionLineStyle( const ScMarkData
& rMark
,
1906 const ::editeng::SvxBorderLine
* pLine
, bool bColorOnly
);
1908 const ScStyleSheet
* GetStyle( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1909 const ScStyleSheet
* GetSelectionStyle( const ScMarkData
& rMark
) const;
1911 void StyleSheetChanged( const SfxStyleSheetBase
* pStyleSheet
, bool bRemoved
,
1913 double nPPTX
, double nPPTY
,
1914 const Fraction
& rZoomX
, const Fraction
& rZoomY
);
1916 bool IsStyleSheetUsed( const ScStyleSheet
& rStyle
) const;
1918 SC_DLLPUBLIC
bool ApplyFlagsTab( SCCOL nStartCol
, SCROW nStartRow
,
1919 SCCOL nEndCol
, SCROW nEndRow
,
1920 SCTAB nTab
, ScMF nFlags
);
1921 SC_DLLPUBLIC
bool RemoveFlagsTab( SCCOL nStartCol
, SCROW nStartRow
,
1922 SCCOL nEndCol
, SCROW nEndRow
,
1923 SCTAB nTab
, ScMF nFlags
);
1925 SC_DLLPUBLIC
void SetPattern( const ScAddress
&, const ScPatternAttr
& rAttr
);
1926 SC_DLLPUBLIC
const ScPatternAttr
* SetPattern( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, std::unique_ptr
<ScPatternAttr
> pAttr
);
1927 SC_DLLPUBLIC
const ScPatternAttr
* SetPattern( const ScAddress
& rPos
, std::unique_ptr
<ScPatternAttr
> pAttr
);
1928 SC_DLLPUBLIC
void SetPattern( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const ScPatternAttr
& rAttr
);
1930 void AutoFormat( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
1931 sal_uInt16 nFormatNo
, const ScMarkData
& rMark
);
1932 void GetAutoFormatData( SCTAB nTab
, SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
1933 ScAutoFormatData
& rData
);
1934 bool SearchAndReplace( const SvxSearchItem
& rSearchItem
,
1935 SCCOL
& rCol
, SCROW
& rRow
, SCTAB
& rTab
,
1936 const ScMarkData
& rMark
, ScRangeList
& rMatchedRanges
,
1937 OUString
& rUndoStr
, ScDocument
* pUndoDoc
, bool& bMatchedRangesWereClamped
);
1938 static bool IsEmptyCellSearch( const SvxSearchItem
& rSearchItem
);
1940 // determine Col/Row of subsequent calls
1941 // (e.g. not found from the beginning, or subsequent tables)
1942 // meaning of explanation in "()" was already unclear in German
1943 void GetSearchAndReplaceStart( const SvxSearchItem
& rSearchItem
,
1944 SCCOL
& rCol
, SCROW
& rRow
);
1946 bool Solver( SCCOL nFCol
, SCROW nFRow
, SCTAB nFTab
,
1947 SCCOL nVCol
, SCROW nVRow
, SCTAB nVTab
,
1948 const OUString
& sValStr
, double& nX
);
1950 SC_DLLPUBLIC
void ApplySelectionPattern( const ScPatternAttr
& rAttr
, const ScMarkData
& rMark
,
1951 ScEditDataArray
* pDataArray
= nullptr, bool* pIsChanged
= nullptr );
1952 SC_DLLPUBLIC
void DeleteSelection( InsertDeleteFlags nDelFlag
, const ScMarkData
& rMark
, bool bBroadcast
= true );
1953 void DeleteSelectionTab( SCTAB nTab
, InsertDeleteFlags nDelFlag
, const ScMarkData
& rMark
);
1955 SC_DLLPUBLIC
void SetColWidth( SCCOL nCol
, SCTAB nTab
, sal_uInt16 nNewWidth
);
1956 SC_DLLPUBLIC
void SetColWidthOnly( SCCOL nCol
, SCTAB nTab
, sal_uInt16 nNewWidth
);
1957 SC_DLLPUBLIC
void SetRowHeight( SCROW nRow
, SCTAB nTab
, sal_uInt16 nNewHeight
);
1958 SC_DLLPUBLIC
void SetRowHeightRange( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
,
1959 sal_uInt16 nNewHeight
);
1961 SC_DLLPUBLIC
void SetRowHeightOnly( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
,
1962 sal_uInt16 nNewHeight
);
1963 SC_DLLPUBLIC
void SetManualHeight( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bManual
);
1965 SC_DLLPUBLIC sal_uInt16
GetColWidth( SCCOL nCol
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
1966 SC_DLLPUBLIC
tools::Long
GetColWidth( SCCOL nStartCol
, SCCOL nEndCol
, SCTAB nTab
) const;
1967 SC_DLLPUBLIC sal_uInt16
GetRowHeight( SCROW nRow
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
1968 SC_DLLPUBLIC sal_uInt16
GetRowHeight( SCROW nRow
, SCTAB nTab
, SCROW
* pStartRow
, SCROW
* pEndRow
, bool bHiddenAsZero
= true ) const;
1969 SC_DLLPUBLIC
tools::Long
GetRowHeight( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
1972 * Given the height i.e. total vertical distance from the top of the sheet
1973 * grid, return the first visible row whose top position is below the
1976 SCROW
GetRowForHeight( SCTAB nTab
, tools::Long nHeight
) const;
1977 tools::Long
GetScaledRowHeight( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, double fScale
) const;
1978 SC_DLLPUBLIC
tools::Long
GetColOffset( SCCOL nCol
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
1979 SC_DLLPUBLIC
tools::Long
GetRowOffset( SCROW nRow
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
1981 SC_DLLPUBLIC sal_uInt16
GetOriginalWidth( SCCOL nCol
, SCTAB nTab
) const;
1982 SC_DLLPUBLIC sal_uInt16
GetOriginalHeight( SCROW nRow
, SCTAB nTab
) const;
1984 sal_uInt16
GetCommonWidth( SCCOL nEndCol
, SCTAB nTab
) const;
1986 SCROW
GetHiddenRowCount( SCROW nRow
, SCTAB nTab
) const;
1988 sal_uInt16
GetOptimalColWidth( SCCOL nCol
, SCTAB nTab
, OutputDevice
* pDev
,
1989 double nPPTX
, double nPPTY
,
1990 const Fraction
& rZoomX
, const Fraction
& rZoomY
,
1992 const ScMarkData
* pMarkData
= nullptr,
1993 const ScColWidthParam
* pParam
= nullptr );
1995 SC_DLLPUBLIC
bool SetOptimalHeight( sc::RowHeightContext
& rCxt
, SCROW nStartRow
,
1996 SCROW nEndRow
, SCTAB nTab
, bool bApi
);
1998 void UpdateAllRowHeights( sc::RowHeightContext
& rCxt
, const ScMarkData
* pTabMark
);
2000 tools::Long
GetNeededSize( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
2002 double nPPTX
, double nPPTY
,
2003 const Fraction
& rZoomX
, const Fraction
& rZoomY
,
2004 bool bWidth
, bool bTotalSize
= false,
2005 bool bInPrintTwips
= false );
2007 SC_DLLPUBLIC
void ShowCol(SCCOL nCol
, SCTAB nTab
, bool bShow
);
2008 SC_DLLPUBLIC
void ShowRow(SCROW nRow
, SCTAB nTab
, bool bShow
);
2009 SC_DLLPUBLIC
void ShowRows(SCROW nRow1
, SCROW nRow2
, SCTAB nTab
, bool bShow
);
2010 SC_DLLPUBLIC
void SetRowFlags( SCROW nRow
, SCTAB nTab
, CRFlags nNewFlags
);
2011 SC_DLLPUBLIC
void SetRowFlags( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, CRFlags nNewFlags
);
2013 SC_DLLPUBLIC CRFlags
GetColFlags( SCCOL nCol
, SCTAB nTab
) const;
2014 SC_DLLPUBLIC CRFlags
GetRowFlags( SCROW nRow
, SCTAB nTab
) const;
2016 SC_DLLPUBLIC
void GetAllRowBreaks(std::set
<SCROW
>& rBreaks
, SCTAB nTab
, bool bPage
, bool bManual
) const;
2017 SC_DLLPUBLIC
void GetAllColBreaks(std::set
<SCCOL
>& rBreaks
, SCTAB nTab
, bool bPage
, bool bManual
) const;
2018 SC_DLLPUBLIC ScBreakType
HasRowBreak(SCROW nRow
, SCTAB nTab
) const;
2019 SC_DLLPUBLIC ScBreakType
HasColBreak(SCCOL nCol
, SCTAB nTab
) const;
2020 SC_DLLPUBLIC
void SetRowBreak(SCROW nRow
, SCTAB nTab
, bool bPage
, bool bManual
);
2021 SC_DLLPUBLIC
void SetColBreak(SCCOL nCol
, SCTAB nTab
, bool bPage
, bool bManual
);
2022 void RemoveRowBreak(SCROW nRow
, SCTAB nTab
, bool bPage
, bool bManual
);
2023 void RemoveColBreak(SCCOL nCol
, SCTAB nTab
, bool bPage
, bool bManual
);
2025 css::sheet::TablePageBreakData
> GetRowBreakData(SCTAB nTab
) const;
2027 SC_DLLPUBLIC
bool RowHidden(SCROW nRow
, SCTAB nTab
, SCROW
* pFirstRow
= nullptr, SCROW
* pLastRow
= nullptr) const;
2028 SC_DLLPUBLIC
bool HasHiddenRows(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2029 SC_DLLPUBLIC
bool ColHidden(SCCOL nCol
, SCTAB nTab
, SCCOL
* pFirstCol
= nullptr, SCCOL
* pLastCol
= nullptr) const;
2030 SC_DLLPUBLIC
void SetRowHidden(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bHidden
);
2031 SC_DLLPUBLIC
void SetColHidden(SCCOL nStartCol
, SCCOL nEndCol
, SCTAB nTab
, bool bHidden
);
2032 SC_DLLPUBLIC SCROW
FirstVisibleRow(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2033 SC_DLLPUBLIC SCROW
LastVisibleRow(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2034 SCROW
CountVisibleRows(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2036 SC_DLLPUBLIC
bool RowFiltered(SCROW nRow
, SCTAB nTab
, SCROW
* pFirstRow
= nullptr, SCROW
* pLastRow
= nullptr) const;
2037 bool HasFilteredRows(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2038 bool ColFiltered(SCCOL nCol
, SCTAB nTab
) const;
2039 SC_DLLPUBLIC
void SetRowFiltered(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bFiltered
);
2040 SCROW
FirstNonFilteredRow(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2041 SCROW
LastNonFilteredRow(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2042 SCROW
CountNonFilteredRows(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2044 SC_DLLPUBLIC
bool IsManualRowHeight(SCROW nRow
, SCTAB nTab
) const;
2046 bool HasUniformRowHeight( SCTAB nTab
, SCROW nRow1
, SCROW nRow2
) const;
2049 * Write all column row flags to table's flag data, because not all column
2050 * row attributes are stored in the flag data members. This is necessary
2053 void SyncColRowFlags();
2055 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
2056 SC_DLLPUBLIC SCROW
GetLastFlaggedRow( SCTAB nTab
) const;
2058 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
2059 SCCOL
GetLastChangedColFlagsWidth( SCTAB nTab
) const;
2060 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
2061 SCROW
GetLastChangedRowFlagsWidth( SCTAB nTab
) const;
2063 SCCOL
GetNextDifferentChangedColFlagsWidth( SCTAB nTab
, SCCOL nStart
) const;
2065 SCROW
GetNextDifferentChangedRowFlagsWidth( SCTAB nTab
, SCROW nStart
) const;
2067 // returns whether to export a Default style for this col or not
2068 // nDefault is set to one position in the current row where the Default style is
2069 void GetColDefault( SCTAB nTab
, SCCOL nCol
, SCROW nLastRow
, SCROW
& nDefault
);
2071 bool UpdateOutlineCol( SCCOL nStartCol
, SCCOL nEndCol
, SCTAB nTab
, bool bShow
);
2072 bool UpdateOutlineRow( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bShow
);
2074 void StripHidden( SCCOL
& rX1
, SCROW
& rY1
, SCCOL
& rX2
, SCROW
& rY2
, SCTAB nTab
);
2075 void ExtendHidden( SCCOL
& rX1
, SCROW
& rY1
, SCCOL
& rX2
, SCROW
& rY2
, SCTAB nTab
);
2077 SC_DLLPUBLIC ScPatternAttr
* GetDefPattern() const;
2078 SC_DLLPUBLIC ScDocumentPool
* GetPool();
2079 SC_DLLPUBLIC ScStyleSheetPool
* GetStyleSheetPool() const;
2080 void GetUnprotectedCells( ScRangeList
& rRange
, SCTAB nTab
) const;
2083 SC_DLLPUBLIC OUString
GetPageStyle( SCTAB nTab
) const;
2084 SC_DLLPUBLIC
void SetPageStyle( SCTAB nTab
, const OUString
& rName
);
2085 Size
GetPageSize( SCTAB nTab
) const;
2086 void SetPageSize( SCTAB nTab
, const Size
& rSize
);
2087 void SetRepeatArea( SCTAB nTab
, SCCOL nStartCol
, SCCOL nEndCol
, SCROW nStartRow
, SCROW nEndRow
);
2088 void InvalidatePageBreaks(SCTAB nTab
);
2089 void UpdatePageBreaks( SCTAB nTab
, const ScRange
* pUserArea
= nullptr );
2090 void RemoveManualBreaks( SCTAB nTab
);
2091 bool HasManualBreaks( SCTAB nTab
) const;
2093 bool IsPageStyleInUse( std::u16string_view rStrPageStyle
, SCTAB
* pInTab
);
2094 bool RemovePageStyleInUse( std::u16string_view rStrPageStyle
);
2095 bool RenamePageStyleInUse( std::u16string_view rOld
, const OUString
& rNew
);
2096 void ModifyStyleSheet( SfxStyleSheetBase
& rPageStyle
,
2097 const SfxItemSet
& rChanges
);
2099 void PageStyleModified( SCTAB nTab
, const OUString
& rNewName
);
2101 SC_DLLPUBLIC
bool NeedPageResetAfterTab( SCTAB nTab
) const;
2103 // Was stored in PageStyle previously. Now it exists for every table:
2104 SC_DLLPUBLIC
bool HasPrintRange();
2105 SC_DLLPUBLIC sal_uInt16
GetPrintRangeCount( SCTAB nTab
);
2106 SC_DLLPUBLIC
const ScRange
* GetPrintRange( SCTAB nTab
, sal_uInt16 nPos
);
2107 SC_DLLPUBLIC
std::optional
<ScRange
> GetRepeatColRange( SCTAB nTab
);
2108 SC_DLLPUBLIC
std::optional
<ScRange
> GetRepeatRowRange( SCTAB nTab
);
2109 /** Returns true, if the specified sheet is always printed. */
2110 bool IsPrintEntireSheet( SCTAB nTab
) const;
2112 /** Removes all print ranges. */
2113 SC_DLLPUBLIC
void ClearPrintRanges( SCTAB nTab
);
2114 /** Adds a new print ranges. */
2115 SC_DLLPUBLIC
void AddPrintRange( SCTAB nTab
, const ScRange
& rNew
);
2116 /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */
2117 SC_DLLPUBLIC
void SetPrintEntireSheet( SCTAB nTab
);
2118 SC_DLLPUBLIC
void SetRepeatColRange( SCTAB nTab
, std::optional
<ScRange
> oNew
);
2119 SC_DLLPUBLIC
void SetRepeatRowRange( SCTAB nTab
, std::optional
<ScRange
> oNew
);
2120 std::unique_ptr
<ScPrintRangeSaver
> CreatePrintRangeSaver() const;
2121 void RestorePrintRanges( const ScPrintRangeSaver
& rSaver
);
2123 SC_DLLPUBLIC
tools::Rectangle
GetMMRect( SCCOL nStartCol
, SCROW nStartRow
,
2124 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
2125 SC_DLLPUBLIC ScRange
GetRange( SCTAB nTab
, const tools::Rectangle
& rMMRect
, bool bHiddenAsZero
= true ) const;
2127 void UpdStlShtPtrsFrmNms();
2128 void StylesToNames();
2130 SC_DLLPUBLIC
void CopyStdStylesFrom( const ScDocument
& rSrcDoc
);
2132 static sal_uInt16
GetSrcVersion() { return nSrcVer
; }
2134 void SetSrcCharSet( rtl_TextEncoding eNew
) { eSrcSet
= eNew
; }
2135 void UpdateFontCharSet();
2137 void FillInfo( ScTableInfo
& rTabInfo
, SCCOL nCol1
, SCROW nRow1
,
2138 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab
, double fColScale
,
2139 double fRowScale
, bool bPageMode
, bool bFormulaMode
,
2140 const ScMarkData
* pMarkData
= nullptr );
2142 SC_DLLPUBLIC SvNumberFormatter
* GetFormatTable() const;
2144 /** Sort a range of data. */
2145 void Sort( SCTAB nTab
, const ScSortParam
& rSortParam
,
2146 bool bKeepQuery
, bool bUpdateRefs
,
2147 ScProgress
* pProgress
, sc::ReorderParam
* pUndo
);
2149 void Reorder( const sc::ReorderParam
& rParam
);
2151 void PrepareQuery( SCTAB nTab
, ScQueryParam
& rQueryParam
);
2152 SCSIZE
Query( SCTAB nTab
, const ScQueryParam
& rQueryParam
, bool bKeepSub
);
2153 SC_DLLPUBLIC
bool CreateQueryParam( const ScRange
& rRange
, ScQueryParam
& rQueryParam
);
2154 OUString
GetUpperCellString(SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
2157 * Get a list of unique strings to use in filtering criteria. The string
2158 * values are sorted, and there are no duplicate values in the list. The
2159 * data range to use to populate the filter entries is inferred from the
2160 * database range that contains the specified cell position.
2162 void GetFilterEntries( SCCOL nCol
, SCROW nRow
,
2163 SCTAB nTab
, ScFilterEntries
& rFilterEntries
);
2165 SC_DLLPUBLIC
void GetFilterEntriesArea( SCCOL nCol
, SCROW nStartRow
, SCROW nEndRow
,
2166 SCTAB nTab
, bool bCaseSens
,
2167 ScFilterEntries
& rFilterEntries
);
2169 void GetDataEntries( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
2170 std::vector
<ScTypedStrData
>& rStrings
, bool bValidation
= false );
2171 void GetFormulaEntries( ScTypedCaseStrSet
& rStrings
);
2173 bool HasAutoFilter( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
2174 void GetFilterSelCount( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, SCSIZE
& nSelected
, SCSIZE
& nTotal
);
2176 SC_DLLPUBLIC
bool HasColHeader( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
2178 SC_DLLPUBLIC
bool HasRowHeader( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
2181 SfxPrinter
* GetPrinter( bool bCreateIfNotExist
= true );
2182 void SetPrinter( VclPtr
<SfxPrinter
> const & pNewPrinter
);
2183 VirtualDevice
* GetVirtualDevice_100th_mm();
2184 SC_DLLPUBLIC OutputDevice
* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
2186 bool GetNextSpellingCell( SCCOL
& nCol
, SCROW
& nRow
, SCTAB nTab
,
2187 bool bInSel
, const ScMarkData
& rMark
) const;
2189 void ReplaceStyle( const SvxSearchItem
& rSearchItem
,
2190 SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
2191 const ScMarkData
& rMark
);
2193 void InvalidateTextWidth( std::u16string_view rStyleName
);
2194 void InvalidateTextWidth( SCTAB nTab
);
2195 void InvalidateTextWidth( const ScAddress
* pAdrFrom
, const ScAddress
* pAdrTo
, bool bNumFormatChanged
);
2197 bool IdleCalcTextWidth();
2199 void RepaintRange( const ScRange
& rRange
);
2200 void RepaintRange( const ScRangeList
& rRange
);
2202 bool IsIdleEnabled() const { return mbIdleEnabled
; }
2203 void EnableIdle(bool bDo
) { mbIdleEnabled
= bDo
; }
2205 bool IsDetectiveDirty() const { return bDetectiveDirty
; }
2206 void SetDetectiveDirty(bool bSet
) { bDetectiveDirty
= bSet
; }
2208 bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck
; }
2209 void SetLinkFormulaNeedingCheck(bool bSet
) { bLinkFormulaNeedingCheck
= bSet
; }
2210 /** Check token array and set link check if ocDde/ocWebservice is contained. */
2211 SC_DLLPUBLIC
void CheckLinkFormulaNeedingCheck( const ScTokenArray
& rCode
);
2213 void SetRangeOverflowType(ErrCode nType
) { nRangeOverflowType
= nType
; }
2214 bool HasRangeOverflow() const { return nRangeOverflowType
!= ERRCODE_NONE
; }
2215 SC_DLLPUBLIC
const ErrCode
& GetRangeOverflowType() const { return nRangeOverflowType
; }
2217 // for broadcasting/listening
2218 void SetInsertingFromOtherDoc( bool bVal
) { bInsertingFromOtherDoc
= bVal
; }
2219 bool IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc
; }
2220 void SetLoadingMedium( bool bVal
);
2221 SC_DLLPUBLIC
void SetImportingXML( bool bVal
);
2222 bool IsImportingXML() const { return bImportingXML
; }
2223 bool IsCalcingAfterLoad() const { return bCalcingAfterLoad
; }
2224 void SetNoListening( bool bVal
) { bNoListening
= bVal
; }
2225 bool GetNoListening() const { return bNoListening
; }
2226 ScBroadcastAreaSlotMachine
* GetBASM() const { return pBASM
.get(); }
2228 SC_DLLPUBLIC ScChartListenerCollection
* GetChartListenerCollection() const { return pChartListenerCollection
.get(); }
2229 void SetChartListenerCollection( std::unique_ptr
<ScChartListenerCollection
>,
2230 bool bSetChartRangeLists
);
2231 void UpdateChart( const OUString
& rName
);
2232 void RestoreChartListener( const OUString
& rName
);
2233 SC_DLLPUBLIC
void UpdateChartListenerCollection();
2234 bool IsChartListenerCollectionNeedsUpdate() const { return bChartListenerCollectionNeedsUpdate
; }
2235 void SetChartListenerCollectionNeedsUpdate( bool bFlg
) { bChartListenerCollectionNeedsUpdate
= bFlg
; }
2236 void AddOLEObjectToCollection(const OUString
& rName
);
2238 ScChangeViewSettings
* GetChangeViewSettings() const { return pChangeViewSettings
.get(); }
2239 SC_DLLPUBLIC
void SetChangeViewSettings(const ScChangeViewSettings
& rNew
);
2241 const std::shared_ptr
<SvxForbiddenCharactersTable
>& GetForbiddenCharacters() const;
2242 void SetForbiddenCharacters(const std::shared_ptr
<SvxForbiddenCharactersTable
>& rNew
);
2244 CharCompressType
GetAsianCompression() const;
2245 bool IsValidAsianCompression() const;
2246 void SetAsianCompression(CharCompressType nNew
);
2248 bool GetAsianKerning() const;
2249 bool IsValidAsianKerning() const;
2250 void SetAsianKerning(bool bNew
);
2251 void ApplyAsianEditSettings(ScEditEngineDefaulter
& rEngine
);
2253 EEHorizontalTextDirection
GetEditTextDirection(SCTAB nTab
) const; // EEHorizontalTextDirection values
2255 SC_DLLPUBLIC ScLkUpdMode
GetLinkMode() const { return eLinkMode
;}
2256 void SetLinkMode( ScLkUpdMode nSet
) { eLinkMode
= nSet
;}
2258 SC_DLLPUBLIC ScMacroManager
* GetMacroManager();
2260 void FillMatrix( ScMatrix
& rMat
, SCTAB nTab
, SCCOL nCol1
,
2261 SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
2262 svl::SharedStringPool
* pPool
= nullptr) const;
2265 * Set an array of numerical formula results to a group of contiguous
2268 * @param rTopPos position of the top formula cell of a group.
2269 * @param pResults array of numeric results.
2270 * @param nLen length of numeric results.
2272 void SC_DLLPUBLIC
SetFormulaResults( const ScAddress
& rTopPos
, const double* pResults
, size_t nLen
);
2274 void CalculateInColumnInThread( ScInterpreterContext
& rContext
, const ScRange
& rCalcRange
, unsigned nThisThread
, unsigned nThreadsTotal
);
2275 void HandleStuffAfterParallelCalculation( SCCOL nColStart
, SCCOL nColEnd
, SCROW nRow
, size_t nLen
, SCTAB nTab
, ScInterpreter
* pInterpreter
);
2278 * Transfer a series of contiguous cell values from specified position to
2279 * the passed container. The specified segment will become empty after the
2282 void TransferCellValuesTo( const ScAddress
& rTopPos
, size_t nLen
, sc::CellValues
& rDest
);
2283 void CopyCellValuesFrom( const ScAddress
& rTopPos
, const sc::CellValues
& rSrc
);
2285 std::set
<Color
> GetDocColors();
2286 sc::IconSetBitmapMap
& GetIconSetBitmapMap();
2288 std::set
<SCCOL
> QueryColumnsWithFormulaCells( SCTAB nTab
) const;
2291 * Check the integrity of the internal table state. Useful from testing
2292 * code. It throws an exception upon first failure.
2294 * Feel free to add more checks as needed.
2296 void CheckIntegrity( SCTAB nTab
) const;
2299 ScDocument(const ScDocument
& r
) = delete;
2301 void FindMaxRotCol( SCTAB nTab
, RowInfo
* pRowInfo
, SCSIZE nArrCount
,
2302 SCCOL nX1
, SCCOL nX2
) const;
2304 sal_uInt16
RowDifferences( SCROW nThisRow
, SCTAB nThisTab
,
2305 ScDocument
& rOtherDoc
,
2306 SCROW nOtherRow
, SCTAB nOtherTab
,
2307 SCCOL nMaxCol
, const SCCOLROW
* pOtherCols
);
2308 sal_uInt16
ColDifferences( SCCOL nThisCol
, SCTAB nThisTab
,
2309 ScDocument
& rOtherDoc
,
2310 SCCOL nOtherCol
, SCTAB nOtherTab
,
2311 SCROW nMaxRow
, const SCCOLROW
* pOtherRows
);
2312 void FindOrder( SCCOLROW
* pOtherRows
, SCCOLROW nThisEndRow
, SCCOLROW nOtherEndRow
,
2314 ScDocument
& rOtherDoc
, SCTAB nThisTab
, SCTAB nOtherTab
,
2315 SCCOLROW nEndCol
, const SCCOLROW
* pTranslate
,
2316 ScProgress
* pProgress
, sal_uInt64 nProAdd
);
2318 DECL_LINK(TrackTimeHdl
, Timer
*, void);
2320 /** Adjust a range to available sheets.
2322 Used to start and stop listening on a sane range. Both o_rRange and
2323 o_bEntirelyOutOfBounds are set only if needed and don't have to be
2324 initialized by the caller.
2326 @param o_bEntirelyOutOfBounds
2327 <TRUE/> if both sheets in the range point outside the
2328 available sheet range, in which case no adjustment is done and
2329 o_rRange is not modified.
2331 @return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds
2333 <FALSE/> if rRange was within the available sheets.
2335 bool LimitRangeToAvailableSheets( const ScRange
& rRange
, ScRange
& o_rRange
,
2336 bool& o_bEntirelyOutOfBounds
) const;
2339 void StartListeningArea( const ScRange
& rRange
, bool bGroupListening
, SvtListener
* pListener
);
2341 void EndListeningArea( const ScRange
& rRange
, bool bGroupListening
, SvtListener
* pListener
);
2342 /** Broadcast wrapper, calls
2343 rHint.GetCell()->Broadcast() and AreaBroadcast()
2347 void Broadcast( const ScHint
& rHint
);
2349 void BroadcastCells( const ScRange
& rRange
, SfxHintId nHint
, bool bBroadcastSingleBroadcasters
= true );
2351 /// only area, no cell broadcast
2352 void AreaBroadcast( const ScHint
& rHint
);
2353 void DelBroadcastAreasInRange( const ScRange
& rRange
);
2354 void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode
,
2355 const ScRange
& rRange
,
2356 SCCOL nDx
, SCROW nDy
, SCTAB nDz
);
2358 void StartListeningCell( const ScAddress
& rAddress
,
2359 SvtListener
* pListener
);
2360 void EndListeningCell( const ScAddress
& rAddress
,
2361 SvtListener
* pListener
);
2363 void StartListeningCell( sc::StartListeningContext
& rCxt
, const ScAddress
& rPos
, SvtListener
& rListener
);
2364 void EndListeningCell( sc::EndListeningContext
& rCxt
, const ScAddress
& rPos
, SvtListener
& rListener
);
2366 void EndListeningFormulaCells( std::vector
<ScFormulaCell
*>& rCells
);
2368 void PutInFormulaTree( ScFormulaCell
* pCell
);
2369 void RemoveFromFormulaTree( ScFormulaCell
* pCell
);
2372 * Calculate formula cells that are on the formula tree either partially,
2375 * @param bOnlyForced when true, it only calculates those formula cells
2376 * that are marked "recalc forced".
2377 * @param bProgressBar whether or not to use progress bar.
2378 * @param bSetAllDirty when true, it marks all formula cells currently on
2379 * the formula tree dirty, which forces all of them to
2380 * be recalculated. When false, only those cells
2381 * that are marked dirty prior to this call get
2384 SC_DLLPUBLIC
void CalcFormulaTree( bool bOnlyForced
= false, bool bProgressBar
= true, bool bSetAllDirty
= true );
2385 void ClearFormulaTree();
2386 void AppendToFormulaTrack( ScFormulaCell
* pCell
);
2387 void RemoveFromFormulaTrack( ScFormulaCell
* pCell
);
2388 void TrackFormulas( SfxHintId nHintId
= SfxHintId::ScDataChanged
);
2389 void SetTrackFormulasPending() { mbTrackFormulasPending
= true; }
2390 bool IsTrackFormulasPending() const { return mbTrackFormulasPending
; }
2391 void FinalTrackFormulas( SfxHintId nHintId
);
2392 bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas
; }
2393 inline bool IsInFormulaTree( const ScFormulaCell
* pCell
) const;
2394 inline bool IsInFormulaTrack( const ScFormulaCell
* pCell
) const;
2395 HardRecalcState
GetHardRecalcState() const { return eHardRecalcState
; }
2396 void SetHardRecalcState( HardRecalcState eVal
) { eHardRecalcState
= eVal
; }
2397 void StartAllListeners();
2398 void StartNeededListeners();
2399 void StartNeededListeners( const std::shared_ptr
<const sc::ColumnSet
>& rpColSet
);
2400 SC_DLLPUBLIC
void StartAllListeners( const ScRange
& rRange
);
2402 void SetForcedFormulas( bool bVal
) { bHasForcedFormulas
= bVal
; }
2403 sal_uInt64
GetFormulaCodeInTree() const { return nFormulaCodeInTree
; }
2405 bool IsInInterpreter() const { return nInterpretLevel
!= 0; }
2407 void IncInterpretLevel()
2409 assert(!IsThreadedGroupCalcInProgress());
2410 if ( nInterpretLevel
< USHRT_MAX
)
2413 void DecInterpretLevel()
2415 assert(!IsThreadedGroupCalcInProgress());
2416 if ( nInterpretLevel
)
2419 sal_uInt16
GetMacroInterpretLevel() const { return nMacroInterpretLevel
; }
2420 void IncMacroInterpretLevel()
2422 assert(!IsThreadedGroupCalcInProgress());
2423 if ( nMacroInterpretLevel
< USHRT_MAX
)
2424 nMacroInterpretLevel
++;
2426 void DecMacroInterpretLevel()
2428 assert(!IsThreadedGroupCalcInProgress());
2429 if ( nMacroInterpretLevel
)
2430 nMacroInterpretLevel
--;
2432 bool IsInInterpreterTableOp() const { return nInterpreterTableOpLevel
!= 0; }
2433 void IncInterpreterTableOpLevel()
2435 if ( nInterpreterTableOpLevel
< USHRT_MAX
)
2436 nInterpreterTableOpLevel
++;
2438 void DecInterpreterTableOpLevel()
2440 if ( nInterpreterTableOpLevel
)
2441 nInterpreterTableOpLevel
--;
2444 // add a formula to be remembered for TableOp broadcasts
2445 void AddTableOpFormulaCell( ScFormulaCell
* );
2446 void InvalidateLastTableOpParams() { aLastTableOpParams
.bValid
= false; }
2447 ScRecursionHelper
& GetRecursionHelper();
2448 bool IsInDtorClear() const { return bInDtorClear
; }
2449 void SetExpandRefs( bool bVal
);
2450 bool IsExpandRefs() const { return bExpandRefs
; }
2452 sal_uInt64
GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount
; }
2453 void IncXMLImportedFormulaCount( sal_uInt64 nVal
)
2455 if ( nXMLImportedFormulaCount
+ nVal
> nXMLImportedFormulaCount
)
2456 nXMLImportedFormulaCount
+= nVal
;
2458 void DecXMLImportedFormulaCount( sal_uInt64 nVal
)
2460 if ( nVal
<= nXMLImportedFormulaCount
)
2461 nXMLImportedFormulaCount
-= nVal
;
2463 nXMLImportedFormulaCount
= 0;
2466 void StartTrackTimer();
2468 void CompileDBFormula();
2469 void CompileColRowNameFormula();
2471 /** Maximum string length of a column, e.g. for dBase export.
2472 @return String length in octets (!) of the destination encoding. In
2473 case of non-octet encodings (e.g. UCS2) the length in code
2474 points times sizeof(sal_Unicode) is returned. */
2475 sal_Int32
GetMaxStringLen( SCTAB nTab
, SCCOL nCol
,
2476 SCROW nRowStart
, SCROW nRowEnd
,
2477 rtl_TextEncoding eCharSet
) const;
2478 /** Maximum string length of numerical cells of a column, e.g. for dBase export.
2479 @return String length in characters (!) including the decimal
2480 separator, and the decimal precision needed. */
2481 sal_Int32
GetMaxNumberStringLen( sal_uInt16
& nPrecision
,
2482 SCTAB nTab
, SCCOL nCol
,
2483 SCROW nRowStart
, SCROW nRowEnd
) const;
2485 void KeyInput(); // TimerDelays etc.
2487 ScChangeTrack
* GetChangeTrack() const { return pChangeTrack
.get(); }
2489 //! only for import filter, deletes any existing ChangeTrack via
2490 //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
2491 SC_DLLPUBLIC
void SetChangeTrack( std::unique_ptr
<ScChangeTrack
> pTrack
);
2493 void StartChangeTracking();
2494 void EndChangeTracking();
2496 SC_DLLPUBLIC
void CompareDocument( ScDocument
& rOtherDoc
);
2498 void AddUnoObject( SfxListener
& rObject
);
2499 void RemoveUnoObject( SfxListener
& rObject
);
2500 void BroadcastUno( const SfxHint
&rHint
);
2501 void AddUnoListenerCall( const css::uno::Reference
<
2502 css::util::XModifyListener
>& rListener
,
2503 const css::lang::EventObject
& rEvent
);
2505 void SetInLinkUpdate(bool bSet
); // TableLink or AreaLink
2506 bool IsInLinkUpdate() const; // including DdeLink
2508 SC_DLLPUBLIC SfxItemPool
* GetEditPool() const;
2509 SC_DLLPUBLIC SfxItemPool
* GetEnginePool() const;
2510 SC_DLLPUBLIC ScFieldEditEngine
& GetEditEngine();
2511 SC_DLLPUBLIC ScNoteEditEngine
& GetNoteEngine();
2513 std::unique_ptr
<EditTextObject
> CreateSharedStringTextObject( const svl::SharedString
& rSS
);
2515 std::unique_ptr
<ScRefreshTimerControl
> const & GetRefreshTimerControlAddress() const
2516 { return pRefreshTimerControl
; }
2518 void SetPastingDrawFromOtherDoc( bool bVal
)
2519 { bPastingDrawFromOtherDoc
= bVal
; }
2520 bool PastingDrawFromOtherDoc() const
2521 { return bPastingDrawFromOtherDoc
; }
2523 /// an ID unique to each document instance
2524 sal_uInt32
GetDocumentID() const;
2526 void InvalidateStyleSheetUsage() { bStyleSheetUsageInvalid
= true; }
2527 void SC_DLLPUBLIC
GetSortParam( ScSortParam
& rParam
, SCTAB nTab
);
2528 void SC_DLLPUBLIC
SetSortParam( const ScSortParam
& rParam
, SCTAB nTab
);
2530 void SetVbaEventProcessor( const css::uno::Reference
< css::script::vba::XVBAEventProcessor
>& rxVbaEvents
)
2531 { mxVbaEvents
= rxVbaEvents
; }
2532 const css::uno::Reference
< css::script::vba::XVBAEventProcessor
>& GetVbaEventProcessor() const { return mxVbaEvents
; }
2534 /** Should only be GRAM_PODF or GRAM_ODFF. */
2535 void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar
);
2536 formula::FormulaGrammar::Grammar
GetStorageGrammar() const { return eStorageGrammar
; }
2538 SC_DLLPUBLIC ScUndoManager
* GetUndoManager();
2539 bool IsInVBAMode() const;
2540 ScRowBreakIterator
* GetRowBreakIterator(SCTAB nTab
) const;
2542 void AddSubTotalCell(ScFormulaCell
* pCell
);
2543 void RemoveSubTotalCell(ScFormulaCell
* pCell
);
2544 void SetSubTotalCellsDirty(const ScRange
& rDirtyRange
);
2546 sal_uInt16
GetTextWidth( const ScAddress
& rPos
) const;
2548 SvtScriptType
GetScriptType( const ScAddress
& rPos
) const;
2549 void SetScriptType( const ScAddress
& rPos
, SvtScriptType nType
);
2550 void UpdateScriptTypes( const ScAddress
& rPos
, SCCOL nColSize
, SCROW nRowSize
);
2553 * Make specified formula cells non-grouped.
2555 * @param nTab sheet index
2556 * @param nCol column index
2557 * @param rRows list of row indices at which formula cells are to be
2558 * unshared. This call sorts the passed row indices and
2559 * removes duplicates, which is why the caller must pass it
2562 void UnshareFormulaCells( SCTAB nTab
, SCCOL nCol
, std::vector
<SCROW
>& rRows
);
2563 void RegroupFormulaCells( SCTAB nTab
, SCCOL nCol
);
2564 SC_DLLPUBLIC
void RegroupFormulaCells( const ScRange
& range
);
2566 formula::FormulaTokenRef
ResolveStaticReference( const ScAddress
& rPos
);
2567 formula::FormulaTokenRef
ResolveStaticReference( const ScRange
& rRange
);
2569 formula::VectorRefArray
FetchVectorRefArray( const ScAddress
& rPos
, SCROW nLength
);
2570 bool HandleRefArrayForParallelism( const ScAddress
& rPos
, SCROW nLength
, const ScFormulaCellGroupRef
& mxGroup
);
2572 void AssertNoInterpretNeeded( const ScAddress
& rPos
, SCROW nLength
);
2576 * Call this before any operations that might trigger one or more formula
2577 * cells to get calculated.
2579 void PrepareFormulaCalc();
2582 * Make sure all of the formula cells in the specified range have been
2583 * fully calculated. This method only re-calculates those formula cells
2584 * that have been flagged dirty. In case of formula-groups, this calculates
2585 * only the dirty subspans along with the dependents in the same way
2588 * @param rRange range in which to potentially calculate the formula
2590 * @param bSkipRunning flag to skip evaluation of formula-cells that are
2591 * marked as already being evaluated.
2592 * @return true if at least one formula-cell in the specified range was dirty
2593 * else returns false.
2595 SC_DLLPUBLIC
bool EnsureFormulaCellResults( const ScRange
& rRange
, bool bSkipRunning
= false );
2597 SvtBroadcaster
* GetBroadcaster( const ScAddress
& rPos
);
2598 const SvtBroadcaster
* GetBroadcaster( const ScAddress
& rPos
) const;
2599 void DeleteBroadcasters( sc::ColumnBlockPosition
& rBlockPos
, const ScAddress
& rTopPos
, SCROW nLength
);
2601 std::optional
<sc::ColumnIterator
> GetColumnIterator( SCTAB nTab
, SCCOL nCol
, SCROW nRow1
, SCROW nRow2
) const;
2602 void CreateColumnIfNotExists( SCTAB nTab
, SCCOL nCol
);
2604 SC_DLLPUBLIC
void StoreTabToCache(SCTAB nTab
, SvStream
& rStrm
) const;
2605 SC_DLLPUBLIC
void RestoreTabFromCache(SCTAB nTab
, SvStream
& rStream
);
2607 #if DUMP_COLUMN_STORAGE
2608 SC_DLLPUBLIC
void DumpColumnStorage( SCTAB nTab
, SCCOL nCol
) const;
2611 #if DEBUG_AREA_BROADCASTER
2612 SC_DLLPUBLIC
void DumpAreaBroadcasters() const;
2615 SC_DLLPUBLIC
void SetCalcConfig( const ScCalcConfig
& rConfig
);
2616 const ScCalcConfig
& GetCalcConfig() const { return maCalcConfig
; }
2617 void ConvertFormulaToValue( const ScRange
& rRange
, sc::TableValues
* pUndo
);
2618 void SwapNonEmpty( sc::TableValues
& rValues
);
2619 void finalizeOutlineImport();
2620 bool TableExists( SCTAB nTab
) const;
2622 // Returns the given column range, first allocating all the columns if necessary.
2623 SC_DLLPUBLIC ScColumnsRange
GetWritableColumnsRange(SCTAB nTab
, SCCOL nColBegin
, SCCOL nColEnd
);
2624 // Returns a column range, clamped to the allocated columns.
2625 SC_DLLPUBLIC ScColumnsRange
GetAllocatedColumnsRange(SCTAB nTab
, SCCOL nColBegin
, SCCOL nColEnd
) const;
2626 // Returns the given range, without any adjustments. One of the variants above may return
2627 // a smaller range (better performance) if the use case is known.
2628 SC_DLLPUBLIC ScColumnsRange
GetColumnsRange(SCTAB nTab
, SCCOL nColBegin
, SCCOL nColEnd
) const;
2630 bool IsInDocShellRecalc() const { return mbDocShellRecalc
; }
2631 void SetDocShellRecalc(bool bSet
) { mbDocShellRecalc
= bSet
; }
2633 bool IsInLayoutStrings() const { return mbLayoutStrings
; }
2634 void SetLayoutStrings(bool bSet
) { mbLayoutStrings
= bSet
; }
2637 * Serializes the specified sheet's geometry data.
2639 * @param nTab is the index of the sheet to operate on.
2640 * @param bColumns - if true it dumps the data for columns, else it does for rows.
2641 * @param eGeomType indicates the type of data to be dumped for rows/columns.
2642 * @return the serialization of the specified sheet's geometry data as an OString.
2644 OString
dumpSheetGeomData(SCTAB nTab
, bool bColumns
, SheetGeomType eGeomType
);
2646 SCCOL
GetLOKFreezeCol(SCTAB nTab
) const;
2647 SCROW
GetLOKFreezeRow(SCTAB nTab
) const;
2648 bool SetLOKFreezeCol(SCCOL nFreezeCol
, SCTAB nTab
);
2649 bool SetLOKFreezeRow(SCROW nFreezeRow
, SCTAB nTab
);
2654 * Use this class as a locale variable to merge number formatter from
2655 * another document, and set NULL pointer to pFormatExchangeList when
2658 class NumFmtMergeHandler
2661 explicit NumFmtMergeHandler(ScDocument
& rDoc
, const ScDocument
& rSrcDoc
);
2662 ~NumFmtMergeHandler();
2668 void MergeNumberFormatter(const ScDocument
& rSrcDoc
);
2670 void ImplCreateOptions(); // Suggestion: switch to on-demand?
2671 void ImplDeleteOptions();
2673 void DeleteDrawLayer();
2674 SC_DLLPUBLIC
bool DrawGetPrintArea( ScRange
& rRange
, bool bSetHor
, bool bSetVer
) const;
2676 void UpdateDrawPrinter();
2677 void UpdateDrawLanguages();
2678 SC_DLLPUBLIC
void InitClipPtrs( ScDocument
* pSourceDoc
);
2680 void LoadDdeLinks(SvStream
& rStream
);
2681 void SaveDdeLinks(SvStream
& rStream
) const;
2683 void DeleteAreaLinksOnTab( SCTAB nTab
);
2684 void UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode
,
2685 const ScRange
& r
, SCCOL nDx
, SCROW nDy
, SCTAB nDz
);
2687 void CopyRangeNamesToClip(ScDocument
* pClipDoc
, const ScRange
& rClipRange
, const ScMarkData
* pMarks
);
2689 bool HasPartOfMerged( const ScRange
& rRange
);
2692 ScTable
* FetchTable( SCTAB nTab
);
2693 const ScTable
* FetchTable( SCTAB nTab
) const;
2695 ScRefCellValue
GetRefCellValue( const ScAddress
& rPos
);
2697 ScRefCellValue
GetRefCellValue( const ScAddress
& rPos
, sc::ColumnBlockPosition
& rBlockPos
);
2699 std::map
< SCTAB
, ScSortParam
> mSheetSortParams
;
2701 SCSIZE
GetPatternCount( SCTAB nTab
, SCCOL nCol
) const;
2702 SCSIZE
GetPatternCount( SCTAB nTab
, SCCOL nCol
, SCROW nRow1
, SCROW nRow2
) const;
2703 void ReservePatternCount( SCTAB nTab
, SCCOL nCol
, SCSIZE nReserve
);
2705 void SharePooledResources( const ScDocument
* pSrcDoc
);
2707 void EndListeningIntersectedGroup(
2708 sc::EndListeningContext
& rCxt
, const ScAddress
& rPos
, std::vector
<ScAddress
>* pGroupPos
);
2710 void EndListeningIntersectedGroups(
2711 sc::EndListeningContext
& rCxt
, const ScRange
& rRange
, std::vector
<ScAddress
>* pGroupPos
);
2713 void EndListeningGroups( const std::vector
<ScAddress
>& rPosArray
);
2714 void SetNeedsListeningGroups( const std::vector
<ScAddress
>& rPosArray
);
2716 bool BroadcastHintInternal( const ScHint
&rHint
);
2719 typedef std::unique_ptr
<ScDocument
, o3tl::default_delete
<ScDocument
>> ScDocumentUniquePtr
;
2722 * Instantiate this to ensure that subsequent modification of
2723 * the document will cause an assertion failure while this is
2726 struct ScMutationDisable
2729 ScMutationDisable(ScDocument
& rDocument
, ScMutationGuardFlags nFlags
)
2730 : mnFlagRestore(rDocument
.mnMutationGuardFlags
)
2731 , mrDocument(rDocument
)
2733 assert((mnFlagRestore
& nFlags
) == 0);
2734 mrDocument
.mnMutationGuardFlags
|= static_cast<size_t>(nFlags
);
2736 ~ScMutationDisable()
2738 mrDocument
.mnMutationGuardFlags
= mnFlagRestore
;
2740 size_t mnFlagRestore
;
2741 ScDocument
& mrDocument
;
2743 ScMutationDisable(ScDocument
& rDocument
, ScMutationGuardFlags nFlags
)
2745 (void)rDocument
; (void)nFlags
;
2751 * A pretty assertion that checks that the relevant bits in
2752 * the @nFlags are not set on the document at entry and exit.
2754 * Its primary use is for debugging threading. As such, an
2755 * @ScMutationDisable is created to forbid mutation, and this
2756 * condition is then asserted on at prominent sites that
2759 struct ScMutationGuard
2762 ScMutationGuard(ScDocument
& rDocument
, ScMutationGuardFlags nFlags
)
2763 : mnFlags(static_cast<size_t>(nFlags
))
2764 , mrDocument(rDocument
)
2766 assert((mrDocument
.mnMutationGuardFlags
& mnFlags
) == 0);
2771 assert((mrDocument
.mnMutationGuardFlags
& mnFlags
) == 0);
2774 ScDocument
& mrDocument
;
2776 ScMutationGuard(ScDocument
& rDocument
, ScMutationGuardFlags nFlags
)
2778 (void)rDocument
; (void)nFlags
;
2783 class ScDocShellRecalcGuard
2788 ScDocShellRecalcGuard(ScDocument
& rDoc
)
2791 assert(!mrDoc
.IsInDocShellRecalc());
2792 mrDoc
.SetDocShellRecalc(true);
2795 ~ScDocShellRecalcGuard()
2797 mrDoc
.SetDocShellRecalc(false);
2801 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */