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"
27 #include <sal/types.h>
29 #include "interpretercontext.hxx"
30 #include "rangelst.hxx"
31 #include "rangenam.hxx"
32 #include "recursionhelper.hxx"
33 #include "tabopparams.hxx"
35 #include <formula/grammar.hxx>
36 #include <formula/types.hxx>
37 #include "typedstrdata.hxx"
38 #include "calcmacros.hxx"
39 #include "calcconfig.hxx"
40 #include "sheetlimits.hxx"
41 #include <o3tl/deleter.hxx>
42 #include <o3tl/sorted_vector.hxx>
43 #include <svl/hint.hxx>
44 #include <svl/typedwhich.hxx>
45 #include <svl/zforlist.hxx>
46 #include <tools/gen.hxx>
47 #include <tools/solar.h>
52 #include <shared_mutex>
55 #include <unordered_map>
58 #include "markdata.hxx"
59 #include "drwlayer.hxx"
61 #include <oox/helper/refvector.hxx>
63 namespace com::sun::star::chart2
{ class XChartDocument
; }
69 struct ConnectionModel
;
73 typedef oox::RefVector
<oox::xls::Connection
> ConnectionVector
;
77 enum class SvtScriptType
: sal_uInt8
;
79 enum class FormulaError
: sal_uInt16
;
80 enum class CharCompressType
;
81 enum class EEHorizontalTextDirection
;
82 namespace editeng
{ class SvxBorderLine
; }
83 namespace formula
{ struct VectorRefArray
; }
86 class SharedStringPool
;
89 namespace tools
{ class Guid
; }
93 struct BroadcasterState
;
94 struct FormulaGroupContext
;
95 class StartListeningContext
;
96 class EndListeningContext
;
97 class CopyFromClipContext
;
99 class RangeColumnSpanSet
;
100 struct ColumnBlockPosition
;
101 struct RefUpdateContext
;
102 class EditTextIterator
;
104 class DocumentStreamAccess
;
105 class DocumentLinkManager
;
108 class RowHeightContext
;
109 struct SetFormulaDirtyContext
;
112 class FormulaGroupAreaListener
;
114 class UpdatedRangeNames
;
115 class TableColumnBlockPositionSet
;
116 class ColumnIterator
;
117 class ExternalDataMapper
;
119 class SparklineGroup
;
128 class SfxBroadcaster
;
131 class SfxObjectShell
;
136 class SfxStyleSheetBase
;
137 class SvMemoryStream
;
138 class SvxBoxInfoItem
;
140 class SvxForbiddenCharactersTable
;
147 class ScAutoFormatData
;
148 class ScBroadcastAreaSlotMachine
;
149 class ScChangeViewSettings
;
150 class ScChartListenerCollection
;
153 class ScConditionalFormat
;
154 class ScConditionalFormatList
;
155 class ScDBCollection
;
160 class ScDocProtection
;
161 class ScDocumentPool
;
163 class ScExtDocOptions
;
164 class ScExternalRefManager
;
166 class ScMacroManager
;
167 class ScOutlineTable
;
168 class ScPrintRangeSaver
;
170 class ScStyleSheetPool
;
172 class ScTableProtection
;
174 class ScValidationData
;
175 class ScValidationDataList
;
178 class ScEditEngineDefaulter
;
179 class ScFieldEditEngine
;
180 class ScNoteEditEngine
;
182 class ScDPCollection
;
184 class ScScriptTypeData
;
187 class ScRefreshTimerControl
;
188 class ScUnoListenerCalls
;
190 class ScRecursionHelper
;
195 class ScAutoNameCache
;
196 class ScTemporaryChartLock
;
198 struct ScLookupCacheMap
;
199 class ScSortedRangeCache
;
200 struct ScSortedRangeCacheMap
;
202 class ScFormulaParserPool
;
204 class ScRowBreakIterator
;
205 struct ScSetStringParam
;
206 struct ScColWidthParam
;
210 class ScEditDataArray
;
211 class EditTextObject
;
212 struct ScRefCellValue
;
214 struct ScSubTotalParam
;
217 class SvtBroadcaster
;
218 enum class ScDBDataPortion
;
219 enum class ScSheetEventId
;
221 class ScColumnsRange
;
222 struct ScFilterEntries
;
223 typedef o3tl::sorted_vector
<sal_uInt32
> ScCondFormatIndexes
;
224 struct ScSheetLimits
;
225 struct ScDataAreaExtras
;
226 enum class ScConditionMode
;
230 typedef std::map
<OUString
, BitmapEx
> IconSetBitmapMap
;
234 namespace com::sun::star
{
239 class XBreakIterator
;
242 class XModifyListener
;
245 class XEmbeddedObject
;
247 namespace script::vba
{
248 class XVBAEventProcessor
;
251 struct TablePageBreakData
;
261 #define SC_DOC_NEW 0xFFFF
263 #define SC_MACROCALL_ALLOWED 0
265 #define SC_ASIANKERNING_INVALID 0xff
272 SCDOCMODE_FUNCTIONACCESS
275 enum CommentCaptionState
277 ALLSHOWN
, // All comments captions are shown
278 ALLHIDDEN
, // All comments captions are hidden
279 MIXED
// There are comments in shown and hidden.
284 GLOBAL
, // A range name can be defined
285 SHEET
// with two scope on Manage Names dialog.
288 /// Represents the type of sheet geometry data.
289 enum class SheetGeomType
291 SIZES
, // Column widths or row heights.
292 HIDDEN
, // Hidden columns/rows.
293 FILTERED
, // Filtered columns/rows.
294 GROUPS
// Grouping of columns/rows.
301 sal_uInt64 nCellCount
;
302 sal_uInt64 nFormulaCount
;
303 sal_uInt16 nPageCount
;
314 const sal_uInt8 SC_DDE_DEFAULT
= 0;
315 const sal_uInt8 SC_DDE_ENGLISH
= 1;
316 const sal_uInt8 SC_DDE_TEXT
= 2;
317 const sal_uInt8 SC_DDE_IGNOREMODE
= 255; /// For usage in FindDdeLink() only!
319 // During threaded calculation fields being mutated are kept in this struct
320 struct ScDocumentThreadSpecific
322 std::unique_ptr
<ScRecursionHelper
> xRecursionHelper
; // information for recursive and iterative cell formulas
323 ScInterpreterContext
* pContext
= nullptr; // references the context passed around for easier access
326 /// Enumeration to determine which pieces of the code should not be mutated when set.
327 enum ScMutationGuardFlags
330 CORE
= 0x0001, /// Core calc data structures should not be mutated
333 // Stores settings used in the Goal Seek
334 struct ScGoalSeekSettings
336 bool bDefined
= false;
337 ScAddress aFormulaCell
;
338 ScAddress aVariableCell
;
339 OUString sTargetValue
;
342 typedef std::unique_ptr
<ScTable
, o3tl::default_delete
<ScTable
>> ScTableUniquePtr
;
346 friend class ScValueIterator
;
347 friend class ScHorizontalValueIterator
;
348 friend class ScDBQueryDataIterator
;
349 friend class ScCellIterator
;
350 template< ScQueryCellIteratorAccess accessType
, ScQueryCellIteratorType queryType
>
351 friend class ScQueryCellIteratorBase
;
352 template< ScQueryCellIteratorAccess accessType
>
353 friend class ScQueryCellIteratorAccessSpecific
;
354 friend class ScHorizontalCellIterator
;
355 friend class ScHorizontalAttrIterator
;
356 friend class ScDocAttrIterator
;
357 friend class ScAttrRectIterator
;
358 friend class ScDocShell
;
359 friend class ScDocRowHeightUpdater
;
360 friend class ScColumnTextWidthIterator
;
361 friend class ScTable
;
362 friend class ScColumn
;
363 friend struct ScRefCellValue
;
364 friend class ScDocumentImport
;
365 friend class sc::EditTextIterator
;
366 friend struct ScMutationGuard
;
367 friend struct ScMutationDisable
;
369 typedef std::vector
<ScTableUniquePtr
> TableContainer
;
372 enum class HardRecalcState
374 OFF
, /// normal calculation of dependencies
375 TEMPORARY
, /// CalcAll() without broadcast/notify but setting up new listeners
376 ETERNAL
/// no new listeners are setup, no broadcast/notify
380 // needs to be shared to allow the bIsClip/bIsUndo mechanism to
381 // do the right thing (SCDOCMODE_CLIP, SCDOCMODE_UNDO)
382 mutable std::shared_ptr
<CellAttributeHelper
> mpCellAttributeHelper
;
385 SC_DLLPUBLIC CellAttributeHelper
& getCellAttributeHelper() const;
387 void setConnectionVector(const ConnectionVector
& rIn
)
389 maConnectionVector
= rIn
;
392 const ConnectionVector
& getConnectionVector() const
394 return maConnectionVector
;
398 rtl::Reference
<ScPoolHelper
> mxPoolHelper
;
400 std::shared_ptr
<svl::SharedStringPool
> mpCellStringPool
;
401 std::unique_ptr
<sc::DocumentLinkManager
> mpDocLinkMgr
;
403 std::shared_ptr
<sc::FormulaGroupContext
> mpFormulaGroupCxt
;
404 bool mbFormulaGroupCxtBlockDiscard
;
406 ScCalcConfig maCalcConfig
;
408 ScUndoManager
* mpUndoManager
;
409 std::unique_ptr
<ScFieldEditEngine
> mpEditEngine
; // uses pEditPool from xPoolHelper
410 std::unique_ptr
<ScNoteEditEngine
> mpNoteEngine
; // uses pEditPool from xPoolHelper
412 VclPtr
<SfxPrinter
> mpPrinter
;
413 VclPtr
<VirtualDevice
> mpVirtualDevice_100th_mm
;
414 std::unique_ptr
<ScDrawLayer
> mpDrawLayer
; // SdrModel
415 rtl::Reference
<XColorList
> pColorList
;
416 std::unique_ptr
<ScValidationDataList
> pValidationList
; // validity
417 SvNumberFormatterIndexTable
* pFormatExchangeList
; // for application of number formats
418 TableContainer maTabs
;
419 rtl::Reference
<ScSheetLimits
> mxSheetLimits
;
420 std::vector
<OUString
> maTabNames
; // for undo document, we need the information tab name <-> index
421 mutable std::unique_ptr
<ScRangeName
> pRangeName
;
422 std::unique_ptr
<ScDBCollection
> pDBCollection
;
423 std::unique_ptr
<ScDPCollection
> pDPCollection
;
424 std::unique_ptr
< ScTemporaryChartLock
> apTemporaryChartLock
;
425 std::unique_ptr
<ScPatternAttr
> pSelectionAttr
; // Attributes of a block
426 ScFormulaCell
* pFormulaTree
; // formula tree (start)
427 ScFormulaCell
* pEOFormulaTree
; // formula tree (end), last cell
428 ScFormulaCell
* pFormulaTrack
; // BroadcastTrack (start)
429 ScFormulaCell
* pEOFormulaTrack
; // BroadcastTrack (end), last cell
430 std::unique_ptr
<ScBroadcastAreaSlotMachine
> pBASM
; // BroadcastAreas
431 std::unique_ptr
<ScChartListenerCollection
> pChartListenerCollection
;
432 std::unique_ptr
<SvMemoryStream
> pClipData
;
433 std::unique_ptr
<ScDetOpList
> pDetOpList
;
434 std::unique_ptr
<ScChangeTrack
> pChangeTrack
;
435 std::unique_ptr
<SfxBroadcaster
> pUnoBroadcaster
;
436 std::unique_ptr
<ScUnoListenerCalls
> pUnoListenerCalls
;
437 std::unique_ptr
<ScUnoRefList
> pUnoRefUndoList
;
438 std::unique_ptr
<ScChangeViewSettings
> pChangeViewSettings
;
439 std::unique_ptr
<ScScriptTypeData
> pScriptTypeData
;
440 std::unique_ptr
<ScRefreshTimerControl
> pRefreshTimerControl
;
441 std::shared_ptr
<SvxForbiddenCharactersTable
> xForbiddenCharacters
;
442 std::unique_ptr
<ScDBData
> mpAnonymousDBData
;
443 std::unique_ptr
<sc::ExternalDataMapper
> mpDataMapper
;
445 std::unique_ptr
<ScFieldEditEngine
> pCacheFieldEditEngine
;
447 std::unique_ptr
<ScDocProtection
> pDocProtection
;
448 std::unique_ptr
<ScClipParam
> mpClipParam
;
450 std::unique_ptr
<ScExternalRefManager
> pExternalRefMgr
;
451 std::unique_ptr
<ScMacroManager
> mpMacroMgr
;
453 // mutable for lazy construction
454 mutable std::unique_ptr
< ScFormulaParserPool
>
455 mxFormulaParserPool
; /// Pool for all external formula parsers used by this document.
457 OUString aDocName
; // optional: name of document
458 OUString aDocCodeName
; // optional: name of document (twice?)
459 OUString maFileURL
; // file URL for copy & paste
460 ScRangePairListRef xColNameRanges
;
461 ScRangePairListRef xRowNameRanges
;
463 std::unique_ptr
<ScViewOptions
> pViewOptions
; // view options
464 std::unique_ptr
<ScDocOptions
> pDocOptions
; // document options
465 std::unique_ptr
<ScExtDocOptions
> pExtDocOptions
; // for import etc.
466 std::unique_ptr
<ScClipOptions
> mpClipOptions
; // clipboard options
467 std::unique_ptr
<ScConsolidateParam
> pConsolidateDlgData
;
468 std::unique_ptr
<ScConditionMode
> pConditionalFormatDialogMode
;
470 std::unique_ptr
<ScAutoNameCache
> pAutoNameCache
; // for automatic name lookup during CompileXML
472 std::unique_ptr
<SfxItemSet
> pPreviewFont
; // convert to std::unique_ptr or whatever
473 ScStyleSheet
* pPreviewCellStyle
;
474 ScMarkData maPreviewSelection
;
475 sal_Int64 nUnoObjectId
; // counted up for UNO objects
477 ErrCode nRangeOverflowType
; // used in (xml) loading for overflow warnings
480 ScAddress aCurTextWidthCalcPos
;
484 css::uno::Reference
< css::script::vba::XVBAEventProcessor
>
487 // Stores Goal Seek settings
488 ScGoalSeekSettings maGoalSeekSettings
;
490 ConnectionVector maConnectionVector
;
492 /// list of ScInterpreterTableOpParams currently in use
493 std::vector
<ScInterpreterTableOpParams
*> m_TableOpList
;
494 ScInterpreterTableOpParams aLastTableOpParams
; // remember last params
498 LanguageType eLanguage
; // default language
499 LanguageType eCjkLanguage
; // default language for asian text
500 LanguageType eCtlLanguage
; // default language for complex text
501 rtl_TextEncoding eSrcSet
; // during reading: source character set
503 /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
504 documents, GRAM_ODFF for ODF 1.2 documents. */
505 formula::FormulaGrammar::Grammar eStorageGrammar
;
507 sal_uInt64 nFormulaCodeInTree
; // formula RPN in the formula tree
508 sal_uInt64 nXMLImportedFormulaCount
; // progress count during XML import
509 sal_uInt16 nInterpretLevel
; // >0 if in interpreter
510 sal_uInt16 nMacroInterpretLevel
; // >0 if macro in interpreter
511 sal_uInt16 nInterpreterTableOpLevel
; // >0 if in interpreter TableOp
513 ScDocumentThreadSpecific maNonThreaded
;
515 // There can be only one ScDocument being calculated in a thread at a time, so we can use a
516 // plain thread_local static member.
517 thread_local
static ScDocumentThreadSpecific maThreadSpecific
;
519 mutable ScInterpreterContext maInterpreterContext
;
521 std::shared_mutex mScLookupMutex
; // protection for thread-unsafe parts of handling ScLookup
522 std::unique_ptr
<ScSortedRangeCacheMap
> mxScSortedRangeCache
; // cache for unsorted lookups
524 static const sal_uInt16 nSrcVer
; // file version (load/save)
525 sal_uInt16 nFormulaTrackCount
;
526 HardRecalcState eHardRecalcState
; // off, temporary, eternal
527 SCTAB nVisibleTab
; // for OLE etc., don't use inside ScDocument
528 SCCOL nPosLeft
; // for OLE etc., don't use inside ScDocument
529 SCROW nPosTop
; // for OLE etc., don't use inside ScDocument
531 ScLkUpdMode eLinkMode
;
533 bool bAutoCalc
; // calculate automatically
534 bool bAutoCalcShellDisabled
; // in/from/for ScDocShell disabled
535 // are there ForcedFormulas which have to be calculated
536 // in interaction with ScDocShell SetDocumentModified,
537 // AutoCalcShellDisabled and TrackFormulas
538 bool bForcedFormulaPending
;
539 bool bCalculatingFormulaTree
;
542 bool bIsFunctionAccess
;
543 bool bIsVisible
; // set from view ctor
545 bool bIsEmbedded
; // display/adjust Embedded area?
547 // no broadcast, construct no listener during insert from a different
548 // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad
549 bool bInsertingFromOtherDoc
;
551 bool bImportingXML
; // special handling of formula text
552 bool bCalcingAfterLoad
; // in CalcAfterLoad TRUE
553 // don't construct/destruct listeners temporarily
556 bool bInLinkUpdate
; // TableLink or AreaLink
557 bool bChartListenerCollectionNeedsUpdate
;
558 // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever)
559 bool bHasForcedFormulas
;
560 // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore)
562 // expand reference if insert column/row takes place at the border
564 // is fetched in each UpdateReference from InputOptions,
565 // assigned, and restored at the end of UpdateReference
567 // for detective update, is set for each change of a formula
568 bool bDetectiveDirty
;
569 // If the pointer is set, formula cells will not be automatically grouped into shared formula groups,
570 // instead the range will be extended to contain all such cells.
571 std::unique_ptr
< ScRange
> pDelayedFormulaGrouping
;
572 // If non-empty, ScColumn::StartListeningFormulaCells() calls may be delayed using this,
573 // avoiding repeated calling for the same cells in the given range. The function will be called once
574 // later for all the cells in the range.
575 std::unordered_map
< ScColumn
*, std::pair
<SCROW
, SCROW
>> pDelayedStartListeningFormulaCells
;
576 // Cells will not delete their broadcasters if delayed, avoiding possible extensive mdds vector changes.
577 bool bDelayedDeletingBroadcasters
;
579 bool bLinkFormulaNeedingCheck
; // valid only after loading, for ocDde and ocWebservice
581 CharCompressType nAsianCompression
;
582 sal_uInt8 nAsianKerning
;
584 bool bPastingDrawFromOtherDoc
;
586 sal_uInt8 nInDdeLinkUpdate
; // originating DDE links (stacked bool)
588 bool bInUnoBroadcast
;
589 bool bInUnoListenerCall
;
590 sal_uInt32 nAdjustHeightLock
;
591 formula::FormulaGrammar::Grammar eGrammar
;
593 mutable bool bStyleSheetUsageInvalid
;
595 bool mbUndoEnabled
:1;
596 bool mbExecuteLinkEnabled
:1;
597 bool mbChangeReadOnlyEnabled
:1; // allow changes in read-only document (for API import filters)
598 bool mbStreamValidLocked
:1;
599 bool mbUserInteractionEnabled
:1; // whether or not to launch any kind of interactive dialogs.
601 sal_Int16 mnNamedRangesLockCount
;
603 std::set
<ScFormulaCell
*> maSubTotalCells
;
606 bool mbEmbedFonts
: 1;
607 bool mbEmbedUsedFontsOnly
: 1;
608 bool mbEmbedFontScriptLatin
: 1;
609 bool mbEmbedFontScriptAsian
: 1;
610 bool mbEmbedFontScriptComplex
: 1;
612 sal_Int32 mnImagePreferredDPI
;
614 std::unique_ptr
<sc::IconSetBitmapMap
> m_pIconSetBitmapMap
;
616 bool mbTrackFormulasPending
: 1;
617 bool mbFinalTrackFormulas
: 1;
618 // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress.
619 bool mbDocShellRecalc
: 1;
620 // This indicates if a ScOutputData::LayoutStrings() is in progress.
621 bool mbLayoutStrings
: 1;
623 size_t mnMutationGuardFlags
;
625 bool mbConnectionXml
= false;
626 bool mbCustomXml
= false;
627 OUString aCustomXmlFragmentPath
;
630 bool IsCellInChangeTrack(const ScAddress
&cell
,Color
*pColCellBorder
);
631 void GetCellChangeTrackNote(const ScAddress
&cell
, OUString
&strTrackText
, bool &pbLeftEdge
);
633 void setHasConnectionXml(bool bUse
) { mbConnectionXml
= bUse
; }
634 bool hasConnectionXml() { return mbConnectionXml
; }
636 void setHasCustomXml(bool bUse
, OUString
& sCustomXmlPath
)
639 aCustomXmlFragmentPath
= sCustomXmlPath
;
641 const OUString
& getCustomXmlItems() { return aCustomXmlFragmentPath
; }
642 bool hasCustomXml() { return mbCustomXml
; }
644 bool IsEmbedFonts() const { return mbEmbedFonts
; }
645 bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly
; }
646 bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin
; }
647 bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian
; }
648 bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex
; }
650 void SetEmbedFonts(bool bUse
) { mbEmbedFonts
= bUse
; }
651 void SetEmbedUsedFontsOnly(bool bUse
) { mbEmbedUsedFontsOnly
= bUse
; }
652 void SetEmbedFontScriptLatin(bool bUse
) { mbEmbedFontScriptLatin
= bUse
; }
653 void SetEmbedFontScriptAsian(bool bUse
) { mbEmbedFontScriptAsian
= bUse
; }
654 void SetEmbedFontScriptComplex(bool bUse
) { mbEmbedFontScriptComplex
= bUse
; }
656 void SetImagePreferredDPI(sal_Int32 nValue
) { mnImagePreferredDPI
= nValue
; }
657 sal_Int32
GetImagePreferredDPI() { return mnImagePreferredDPI
; }
659 SC_DLLPUBLIC sal_uInt64
GetCellCount() const; // all cells
660 SC_DLLPUBLIC sal_uInt64
GetFormulaGroupCount() const; // all cells
661 sal_uInt64
GetCodeCount() const; // RPN-Code in formulas
662 DECL_LINK( GetUserDefinedColor
, sal_uInt16
, Color
* );
665 SC_DLLPUBLIC
ScDocument( ScDocumentMode eMode
= SCDOCMODE_DOCUMENT
,
666 ScDocShell
* pDocShell
= nullptr );
667 SC_DLLPUBLIC
~ScDocument();
669 void SetName( const OUString
& r
) { aDocName
= r
; }
670 const OUString
& GetCodeName() const { return aDocCodeName
; }
671 void SetCodeName( const OUString
& r
) { aDocCodeName
= r
; }
672 const OUString
& GetFileURL() const { return maFileURL
; }
674 void GetDocStat( ScDocStat
& rDocStat
);
676 SC_DLLPUBLIC
void InitDrawLayer( ScDocShell
* pDocShell
= nullptr );
678 ScInterpreterContext
& GetNonThreadedContext() const
680 assert(!IsThreadedGroupCalcInProgress());
681 return maInterpreterContext
;
683 // Uses thread_local.
684 ScInterpreterContext
& GetThreadedContext() const
686 return IsThreadedGroupCalcInProgress() ? *maThreadSpecific
.pContext
: GetNonThreadedContext();
688 void SetupContextFromNonThreadedContext( ScInterpreterContext
& threadedContext
, int threadNumber
);
689 void MergeContextBackIntoNonThreadedContext( ScInterpreterContext
& threadedContext
, int threadNumber
);
690 void SetThreadedGroupCalcInProgress( bool set
) { (void)this; ScGlobal::bThreadedGroupCalcInProgress
= set
; }
691 bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress
; }
693 SC_DLLPUBLIC
sfx2::LinkManager
* GetLinkManager();
694 SC_DLLPUBLIC
const sfx2::LinkManager
* GetLinkManager() const;
696 sc::DocumentLinkManager
& GetDocLinkManager();
697 const sc::DocumentLinkManager
& GetDocLinkManager() const;
699 SC_DLLPUBLIC
const ScDocOptions
& GetDocOptions() const;
700 SC_DLLPUBLIC
void SetDocOptions( const ScDocOptions
& rOpt
);
701 SC_DLLPUBLIC
const ScViewOptions
& GetViewOptions() const;
702 SC_DLLPUBLIC
void SetViewOptions( const ScViewOptions
& rOpt
);
703 void SetPrintOptions();
705 ScExtDocOptions
* GetExtDocOptions() { return pExtDocOptions
.get(); }
706 SC_DLLPUBLIC
void SetExtDocOptions( std::unique_ptr
<ScExtDocOptions
> pNewOptions
);
708 ScClipOptions
* GetClipOptions() { return mpClipOptions
.get(); }
709 void SetClipOptions(std::unique_ptr
<ScClipOptions
> pClipOptions
);
711 SC_DLLPUBLIC
void GetLanguage( LanguageType
& rLatin
, LanguageType
& rCjk
, LanguageType
& rCtl
) const;
712 void SetLanguage( LanguageType eLatin
, LanguageType eCjk
, LanguageType eCtl
);
714 void SetConsolidateDlgData( std::unique_ptr
<ScConsolidateParam
> pData
);
715 const ScConsolidateParam
* GetConsolidateDlgData() const { return pConsolidateDlgData
.get(); }
716 void SetEasyConditionalFormatDialogData(std::unique_ptr
<ScConditionMode
> pMode
);
717 const ScConditionMode
* GetEasyConditionalFormatDialogData() const
719 return pConditionalFormatDialogMode
.get();
722 void Clear( bool bFromDestructor
= false );
724 std::unique_ptr
<ScFieldEditEngine
> CreateFieldEditEngine();
725 void DisposeFieldEditEngine(std::unique_ptr
<ScFieldEditEngine
>& rpEditEngine
);
728 * Get all range names that are local to each table. It only returns
729 * non-empty range name set.
731 SC_DLLPUBLIC
void GetAllTabRangeNames(ScRangeName::TabNameCopyMap
& rRangeNames
) const;
732 SC_DLLPUBLIC
void SetAllRangeNames(const std::map
<OUString
, ScRangeName
>& rRangeMap
);
733 SC_DLLPUBLIC
void GetRangeNameMap(std::map
<OUString
, ScRangeName
*>& rRangeName
);
734 SC_DLLPUBLIC ScRangeName
* GetRangeName(SCTAB nTab
) const;
735 SC_DLLPUBLIC ScRangeName
* GetRangeName() const;
736 void SetRangeName(SCTAB nTab
, std::unique_ptr
<ScRangeName
> pNew
);
737 void SetRangeName( std::unique_ptr
<ScRangeName
> pNewRangeName
);
738 bool IsAddressInRangeName( RangeNameScope eScope
, const ScAddress
& rAddress
);
740 /** Find a named expression / range name in either global or a local scope.
742 If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab.
744 Index of named expression / range name.
745 @return nullptr if indexed name not found.
747 ScRangeData
* FindRangeNameBySheetAndIndex( SCTAB nTab
, sal_uInt16 nIndex
) const;
749 /** Recursively find all named expressions that directly or indirectly
750 (nested) reference a given sheet, starting from a given named
751 expression nTokenTab/nTokenIndex.
753 Used to collect all named expressions/ranges that will need to be
754 copied along when copying sheets.
756 The different tab/sheets passed cater for the situation that a sheet is
757 copied and was already inserted and global names are already adjusted
758 but the sheet-local names of the shifted original sheet are not yet. If
759 no sheet was inserted and global and local names' references not
760 updated yet, then all 4 tab arguments would be identical.
763 Tab/sheet on which to find the name, -1 if global scope.
764 For example obtained from ocName token.
767 Index of named expression. For example obtained from ocName token.
770 Tab to check if used in global names.
773 Tab to check if used in sheet-local names.
776 The original tab of the copied sheet, used as sheet-local
777 base position for relative references.
779 @param nOldTokenTabReplacement
780 The replacement to use for relative references if the name
781 encountered uses nOldTokenTab as base position.
784 FALSE if collecting names for a sheet to be copied to another
785 document. Then all names encountered are considered to be
786 referencing the sheet. Else TRUE if collecting names to be
787 copied into the same document.
790 Recursion guard, initialize with 0.
792 bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames
& rIndexes
,
793 SCTAB nTokenTab
, const sal_uInt16 nTokenIndex
,
794 SCTAB nGlobalRefTab
, SCTAB nLocalRefTab
, SCTAB nOldTokenTab
, SCTAB nOldTokenTabReplacement
,
795 bool bSameDoc
, int nRecursion
) const;
797 /** If necessary (name references sheet rOldPos.Tab()) copy and adjust
798 named expression/range from sheet-local to sheet-local, or global to
799 sheet-local if bGlobalNamesToLocal==true.
801 Also copies nested names and adjusts the ocName tokens of the calling name.
804 On entry, the original sheet of the named expression/range, <0 global.
805 On return TRUE, the new sheet. Else unchanged.
808 On entry, the original index of the named expression/range.
809 On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged.
812 On entry, the pointer to the original named expression/range.
813 On return TRUE, the pointer to the new copied name, or nullptr if hits happened.
816 New position of formula cell if called for that, else new base
817 position of a to be created new name adjusted for Tab.
818 rNewPos.nTab MUST point to the new sheet copied to.
821 Old position of formula cell if called for that, else base
822 position of the existing name adjusted for Tab.
823 rOldPos.nTab MUST point to the old sheet copied from.
825 @param bGlobalNamesToLocal
826 If TRUE, affected global names are copied to sheet-local names.
827 If FALSE, global names are copied to global names in another document.
829 @param bUsedByFormula
830 If TRUE, forces a global name to be affected/used.
831 If FALSE, a global name is only affected if it evaluates to be
832 referencing the sheet.
834 @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex.
835 FALSE if nothing to be done.
837 bool CopyAdjustRangeName( SCTAB
& rSheet
, sal_uInt16
& rIndex
, ScRangeData
*& rpRangeData
, ScDocument
& rNewDoc
,
838 const ScAddress
& rNewPos
, const ScAddress
& rOldPos
, const bool bGlobalNamesToLocal
,
839 const bool bUsedByFormula
) const;
842 * Call this immediately before updating all named ranges.
844 SC_DLLPUBLIC
void PreprocessAllRangeNamesUpdate( const std::map
<OUString
, ScRangeName
>& rRangeMap
);
845 SC_DLLPUBLIC
void PreprocessRangeNameUpdate();
846 SC_DLLPUBLIC
void PreprocessDBDataUpdate();
848 * Call this immediately after updating named ranges.
850 SC_DLLPUBLIC
void CompileHybridFormula();
853 * Insert a new named expression to the global scope.
855 * @param rName name for the expression.
856 * @param rPos base position.
857 * @param rExpr formula expression to be associated with the name. The
858 * current grammar is used to compile this expression.
860 * @return true if inserted successfully, false otherwise.
862 bool InsertNewRangeName( const OUString
& rName
, const ScAddress
& rPos
, const OUString
& rExpr
);
865 * Insert a new named expression to a sheet-local scope.
867 * @param nTab sheet for local scope.
868 * @param rName name for the expression.
869 * @param rPos base position.
870 * @param rExpr formula expression to be associated with the name. The
871 * current grammar is used to compile this expression.
873 * @return true if inserted successfully, false otherwise.
875 bool InsertNewRangeName( SCTAB nTab
, const OUString
& rName
, const ScAddress
& rPos
, const OUString
& rExpr
);
877 /** Obtain the sheet separator corresponding to the document's grammar.
879 @return '.' for our own grammars, '!' for Excel grammars.
881 SC_DLLPUBLIC sal_Unicode
GetSheetSeparator() const;
883 SCTAB
GetMaxTableNumber() const { return static_cast<SCTAB
>(maTabs
.size()) - 1; }
885 ScRangePairList
* GetColNameRanges() { return xColNameRanges
.get(); }
886 ScRangePairList
* GetRowNameRanges() { return xRowNameRanges
.get(); }
887 ScRangePairListRef
& GetColNameRangesRef() { return xColNameRanges
; }
888 ScRangePairListRef
& GetRowNameRangesRef() { return xRowNameRanges
; }
890 SC_DLLPUBLIC SCCOL
ClampToAllocatedColumns(SCTAB nTab
, SCCOL nCol
) const;
891 SC_DLLPUBLIC SCCOL
GetAllocatedColumnsCount(SCTAB nTab
) const;
893 SC_DLLPUBLIC ScDBCollection
* GetDBCollection() const { return pDBCollection
.get();}
894 void SetDBCollection( std::unique_ptr
<ScDBCollection
> pNewDBCollection
,
895 bool bRemoveAutoFilter
= false );
896 const ScDBData
* GetDBAtCursor(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, ScDBDataPortion ePortion
) const;
897 ScDBData
* GetDBAtCursor(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, ScDBDataPortion ePortion
);
898 SC_DLLPUBLIC
const ScDBData
* GetDBAtArea(SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
) const;
899 SC_DLLPUBLIC ScDBData
* GetDBAtArea(SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
900 void RefreshDirtyTableColumnNames();
901 SC_DLLPUBLIC
sc::ExternalDataMapper
& GetExternalDataMapper();
903 SC_DLLPUBLIC
const ScRangeData
* GetRangeAtBlock( const ScRange
& rBlock
, OUString
& rName
,
904 bool* pSheetLocal
= nullptr ) const;
906 SC_DLLPUBLIC
bool HasPivotTable() const;
907 SC_DLLPUBLIC ScDPCollection
* GetDPCollection();
908 SC_DLLPUBLIC
const ScDPCollection
* GetDPCollection() const;
909 SC_DLLPUBLIC ScDPObject
* GetDPAtCursor(SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
910 SC_DLLPUBLIC ScDPObject
* GetDPAtCursor(ScAddress
const& rAddress
) const
912 return GetDPAtCursor(rAddress
.Col(), rAddress
.Row(), rAddress
.Tab());
914 SC_DLLPUBLIC
bool HasDataPilotAtPosition(ScAddress
const& rAddress
) const
916 return GetDPAtCursor(rAddress
) != nullptr;
918 ScDPObject
* GetDPAtBlock( const ScRange
& rBlock
) const;
920 void StopTemporaryChartLock();
922 void EnsureGraphicNames();
924 SdrObject
* GetObjectAtPoint( SCTAB nTab
, const Point
& rPos
);
925 bool HasChartAtPoint( SCTAB nTab
, const Point
& rPos
, OUString
& rName
);
927 css::uno::Reference
< css::chart2::XChartDocument
> GetChartByName( std::u16string_view rChartName
);
929 SC_DLLPUBLIC
void GetChartRanges( std::u16string_view rChartName
, std::vector
< ScRangeList
>& rRanges
, const ScDocument
& rSheetNameDoc
);
930 void SetChartRanges( std::u16string_view rChartName
, const std::vector
< ScRangeList
>& rRanges
);
932 void UpdateChartArea( const OUString
& rChartName
, const ScRange
& rNewArea
,
933 bool bColHeaders
, bool bRowHeaders
, bool bAdd
);
934 void UpdateChartArea( const OUString
& rChartName
,
935 const ScRangeListRef
& rNewList
,
936 bool bColHeaders
, bool bRowHeaders
, bool bAdd
);
937 void GetOldChartParameters( std::u16string_view rName
,
938 ScRangeList
& rRanges
, bool& rColHeaders
, bool& rRowHeaders
);
940 css::embed::XEmbeddedObject
>
941 FindOleObjectByName( std::u16string_view rName
);
943 SC_DLLPUBLIC
void MakeTable( SCTAB nTab
,bool _bNeedsNameCheck
= true );
945 SCTAB
GetVisibleTab() const { return nVisibleTab
; }
946 SC_DLLPUBLIC
void SetVisibleTab(SCTAB nTab
) { nVisibleTab
= nTab
; }
947 SCCOL
GetPosLeft() const { return nPosLeft
; }
948 SC_DLLPUBLIC
void SetPosLeft(SCCOL nCol
) { nPosLeft
= nCol
; }
949 SCROW
GetPosTop() const { return nPosTop
; }
950 SC_DLLPUBLIC
void SetPosTop(SCROW nRow
) { nPosTop
= nRow
; }
952 SC_DLLPUBLIC
bool HasTable( SCTAB nTab
) const;
953 SC_DLLPUBLIC
bool GetHashCode( SCTAB nTab
, sal_Int64
& rHashCode
) const;
954 SC_DLLPUBLIC
bool GetName( SCTAB nTab
, OUString
& rName
) const;
955 SC_DLLPUBLIC
bool GetCodeName( SCTAB nTab
, OUString
& rName
) const;
956 SC_DLLPUBLIC
bool SetCodeName( SCTAB nTab
, const OUString
& rName
);
957 SC_DLLPUBLIC
bool GetTotalsRowBelow( SCTAB nTab
) const;
958 SC_DLLPUBLIC
bool SetTotalsRowBelow( SCTAB nTab
, bool bVal
);
959 SC_DLLPUBLIC
bool GetTable( const OUString
& rName
, SCTAB
& rTab
) const;
960 SC_DLLPUBLIC SCCOL
MaxCol() const { return mxSheetLimits
->mnMaxCol
; }
961 SC_DLLPUBLIC SCROW
MaxRow() const { return mxSheetLimits
->mnMaxRow
; }
962 SC_DLLPUBLIC SCCOL
GetMaxColCount() const { return mxSheetLimits
->GetMaxColCount(); }
963 SC_DLLPUBLIC SCROW
GetMaxRowCount() const { return mxSheetLimits
->GetMaxRowCount(); }
964 SC_DLLPUBLIC
const OUString
& MaxRowAsString() const { return mxSheetLimits
->MaxRowAsString(); }
965 SC_DLLPUBLIC
const OUString
& MaxColAsString() const { return mxSheetLimits
->MaxColAsString(); }
966 ScSheetLimits
& GetSheetLimits() const { return *mxSheetLimits
; }
967 [[nodiscard
]] bool ValidCol(SCCOL nCol
) const { return ::ValidCol(nCol
, mxSheetLimits
->mnMaxCol
); }
968 [[nodiscard
]] bool ValidRow(SCROW nRow
) const { return ::ValidRow(nRow
, mxSheetLimits
->mnMaxRow
); }
969 [[nodiscard
]] bool ValidColRow(SCCOL nCol
, SCROW nRow
) const { return ::ValidColRow(nCol
, nRow
, MaxCol(), MaxRow()); }
970 [[nodiscard
]] bool ValidColRowTab(SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const { return ::ValidColRowTab(nCol
, nRow
, nTab
, MaxCol(), MaxRow()); }
971 [[nodiscard
]] bool ValidRange(const ScRange
& rRange
) const { return ::ValidRange(rRange
, MaxCol(), MaxRow()); }
972 [[nodiscard
]] bool ValidAddress(const ScAddress
& rAddress
) const { return ::ValidAddress(rAddress
, MaxCol(), MaxRow()); }
973 [[nodiscard
]] SCCOL
SanitizeCol( SCCOL nCol
) const { return ::SanitizeCol(nCol
, MaxCol()); }
974 [[nodiscard
]] SCROW
SanitizeRow( SCROW nRow
) const { return ::SanitizeRow(nRow
, MaxRow()); }
976 SC_DLLPUBLIC
std::vector
<OUString
> GetAllTableNames() const;
978 const OUString
& GetCopyTabName(SCTAB nTab
) const;
980 SC_DLLPUBLIC
void SetAnonymousDBData(SCTAB nTab
, std::unique_ptr
<ScDBData
> pDBData
);
981 SC_DLLPUBLIC ScDBData
* GetAnonymousDBData(SCTAB nTab
);
983 /** One document global anonymous database range for temporary operations,
984 used if the corresponding sheet-local anonymous database range is
985 already used with AutoFilter and range differs. Not stored in document
987 SC_DLLPUBLIC
void SetAnonymousDBData(std::unique_ptr
<ScDBData
> pDBData
);
988 SC_DLLPUBLIC ScDBData
* GetAnonymousDBData();
990 SC_DLLPUBLIC SCTAB
GetTableCount() const;
991 SvNumberFormatterIndexTable
* GetFormatExchangeList() const { return pFormatExchangeList
; }
993 SC_DLLPUBLIC ScDocProtection
* GetDocProtection() const;
994 SC_DLLPUBLIC
void SetDocProtection(const ScDocProtection
* pProtect
);
995 SC_DLLPUBLIC
bool IsDocProtected() const;
996 bool IsDocEditable() const;
997 SC_DLLPUBLIC
bool IsTabProtected( SCTAB nTab
) const;
998 SC_DLLPUBLIC
const ScTableProtection
* GetTabProtection(SCTAB nTab
) const;
999 SC_DLLPUBLIC
void SetTabProtection(SCTAB nTab
, const ScTableProtection
* pProtect
);
1000 void CopyTabProtection(SCTAB nTabSrc
, SCTAB nTabDest
);
1002 void LockTable(SCTAB nTab
);
1003 void UnlockTable(SCTAB nTab
);
1005 bool IsBlockEditable( SCTAB nTab
, SCCOL nStartCol
, SCROW nStartRow
,
1006 SCCOL nEndCol
, SCROW nEndRow
,
1007 bool* pOnlyNotBecauseOfMatrix
= nullptr,
1008 bool bNoMatrixAtAll
= false ) const;
1009 bool IsSelectionEditable( const ScMarkData
& rMark
,
1010 bool* pOnlyNotBecauseOfMatrix
= nullptr ) const;
1011 bool HasSelectedBlockMatrixFragment( SCCOL nStartCol
, SCROW nStartRow
,
1012 SCCOL nEndCol
, SCROW nEndRow
,
1013 const ScMarkData
& rMark
) const;
1015 bool IsEditActionAllowed( sc::EditAction eAction
, SCTAB nTab
, SCCOL nStartCol
, SCROW nStartRow
,
1016 SCCOL nEndCol
, SCROW nEndRow
) const;
1017 bool IsEditActionAllowed( sc::EditAction eAction
, const ScMarkData
& rMark
, SCCOL nStartCol
,
1018 SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
) const;
1020 SC_DLLPUBLIC
bool GetMatrixFormulaRange( const ScAddress
& rCellPos
, ScRange
& rMatrix
);
1022 bool IsEmbedded() const { return bIsEmbedded
;}
1023 void GetEmbedded( ScRange
& rRange
) const;
1024 void SetEmbedded( const ScRange
& rRange
);
1025 void ResetEmbedded();
1026 tools::Rectangle
GetEmbeddedRect() const; // 1/100 mm
1027 void SetEmbedded( SCTAB nTab
, const tools::Rectangle
& rRect
); // from VisArea (1/100 mm)
1029 static SC_DLLPUBLIC
bool ValidTabName( const OUString
& rName
);
1031 SC_DLLPUBLIC
bool ValidNewTabName( const OUString
& rName
) const;
1032 SC_DLLPUBLIC
void CreateValidTabName(OUString
& rName
) const;
1033 SC_DLLPUBLIC
void CreateValidTabNames(std::vector
<OUString
>& aNames
, SCTAB nCount
) const;
1035 void AppendTabOnLoad(const OUString
& rName
);
1036 void SetTabNameOnLoad(SCTAB nTab
, const OUString
& rName
);
1037 void InvalidateStreamOnSave();
1039 SC_DLLPUBLIC
bool InsertTab( SCTAB nPos
, const OUString
& rName
,
1040 bool bExternalDocument
= false, bool bUndoDeleteTab
= false );
1042 SC_DLLPUBLIC
bool InsertTabs( SCTAB nPos
, const std::vector
<OUString
>& rNames
,
1043 bool bNamesValid
= false );
1044 SC_DLLPUBLIC
bool DeleteTabs( SCTAB nTab
, SCTAB nSheets
);
1045 SC_DLLPUBLIC
bool DeleteTab( SCTAB nTab
);
1046 SC_DLLPUBLIC
bool RenameTab( SCTAB nTab
, const OUString
& rName
,
1047 bool bExternalDocument
= false );
1048 bool MoveTab( SCTAB nOldPos
, SCTAB nNewPos
, ScProgress
* pProgress
= nullptr );
1049 SC_DLLPUBLIC
bool CopyTab( SCTAB nOldPos
, SCTAB nNewPos
,
1050 const ScMarkData
* pOnlyMarked
= nullptr );
1051 SC_DLLPUBLIC
bool TransferTab(ScDocument
& rSrcDoc
, SCTAB nSrcPos
, SCTAB nDestPos
,
1052 bool bInsertNew
= true,
1053 bool bResultsOnly
= false );
1054 SC_DLLPUBLIC
void TransferDrawPage(const ScDocument
& rSrcDoc
, SCTAB nSrcPos
, SCTAB nDestPos
);
1055 SC_DLLPUBLIC
void SetVisible( SCTAB nTab
, bool bVisible
);
1056 SC_DLLPUBLIC
bool IsVisible( SCTAB nTab
) const;
1057 bool IsStreamValid( SCTAB nTab
) const;
1058 void SetStreamValid( SCTAB nTab
, bool bSet
, bool bIgnoreLock
= false );
1059 void LockStreamValid( bool bLock
);
1060 bool IsStreamValidLocked() const { return mbStreamValidLocked
; }
1061 bool IsPendingRowHeights( SCTAB nTab
) const;
1062 void SetPendingRowHeights( SCTAB nTab
, bool bSet
);
1063 sal_uInt16
GetSheetOptimalMinRowHeight(SCTAB nTab
) const;
1064 SC_DLLPUBLIC
void SetLayoutRTL( SCTAB nTab
, bool bRTL
, ScObjectHandling eObjectHandling
= ScObjectHandling::RecalcPosMode
);
1065 SC_DLLPUBLIC
bool IsLayoutRTL( SCTAB nTab
) const;
1066 SC_DLLPUBLIC
bool IsNegativePage( SCTAB nTab
) const;
1067 SC_DLLPUBLIC
void SetScenario( SCTAB nTab
, bool bFlag
);
1068 SC_DLLPUBLIC
bool IsScenario( SCTAB nTab
) const;
1069 SC_DLLPUBLIC
void GetScenarioData(SCTAB nTab
, OUString
& rComment
,
1070 Color
& rColor
, ScScenarioFlags
&rFlags
) const;
1071 SC_DLLPUBLIC
void SetScenarioData(SCTAB nTab
, const OUString
& rComment
,
1072 const Color
& rColor
, ScScenarioFlags nFlags
);
1073 SC_DLLPUBLIC Color
GetTabBgColor( SCTAB nTab
) const;
1074 SC_DLLPUBLIC
void SetTabBgColor( SCTAB nTab
, const Color
& rColor
);
1075 SC_DLLPUBLIC
bool IsDefaultTabBgColor( SCTAB nTab
) const;
1076 void GetScenarioFlags(SCTAB nTab
, ScScenarioFlags
&rFlags
) const;
1077 SC_DLLPUBLIC
bool IsActiveScenario( SCTAB nTab
) const;
1078 SC_DLLPUBLIC
void SetActiveScenario( SCTAB nTab
, bool bActive
); // only for Undo etc.
1079 SC_DLLPUBLIC
formula::FormulaGrammar::AddressConvention
GetAddressConvention() const;
1080 SC_DLLPUBLIC
formula::FormulaGrammar::Grammar
GetGrammar() const { return eGrammar
;}
1081 SC_DLLPUBLIC
void SetGrammar( formula::FormulaGrammar::Grammar eGram
);
1082 SC_DLLPUBLIC ScLinkMode
GetLinkMode( SCTAB nTab
) const;
1083 bool IsLinked( SCTAB nTab
) const;
1084 SC_DLLPUBLIC OUString
GetLinkDoc( SCTAB nTab
) const;
1085 OUString
GetLinkFlt( SCTAB nTab
) const;
1086 OUString
GetLinkOpt( SCTAB nTab
) const;
1087 SC_DLLPUBLIC OUString
GetLinkTab( SCTAB nTab
) const;
1088 sal_Int32
GetLinkRefreshDelay( SCTAB nTab
) const;
1089 void SetLink( SCTAB nTab
, ScLinkMode nMode
, const OUString
& rDoc
,
1090 const OUString
& rFilter
, const OUString
& rOptions
,
1091 const OUString
& rTabName
, sal_Int32 nRefreshDelay
);
1092 bool HasLink( std::u16string_view rDoc
,
1093 std::u16string_view rFilter
, std::u16string_view rOptions
) const;
1094 SC_DLLPUBLIC
bool LinkExternalTab( SCTAB
& nTab
, const OUString
& aDocTab
,
1095 const OUString
& aFileName
,
1096 const OUString
& aTabName
);
1098 bool HasExternalRefManager() const { return bool(pExternalRefMgr
); }
1099 SC_DLLPUBLIC ScExternalRefManager
* GetExternalRefManager() const;
1100 bool IsInExternalReferenceMarking() const;
1101 void MarkUsedExternalReferences();
1102 bool MarkUsedExternalReferences( const ScTokenArray
& rArr
, const ScAddress
& rPos
);
1104 /** Returns the pool containing external formula parsers. Creates the pool
1106 ScFormulaParserPool
& GetFormulaParserPool() const;
1108 bool HasAreaLinks() const;
1109 void UpdateExternalRefLinks(weld::Window
* pWin
);
1110 void UpdateAreaLinks();
1112 // originating DDE links
1113 void IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate
< 255 ) ++nInDdeLinkUpdate
; }
1114 void DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate
) --nInDdeLinkUpdate
; }
1115 bool IsInDdeLinkUpdate() const { return nInDdeLinkUpdate
!= 0; }
1117 SC_DLLPUBLIC
void CopyDdeLinks( ScDocument
& rDestDoc
) const;
1119 /** Tries to find a DDE link with the specified connection data.
1120 @param rnDdePos (out-param) Returns the index of the DDE link (does not include other links from link manager).
1121 @return true = DDE link found, rnDdePos valid. */
1122 SC_DLLPUBLIC
bool FindDdeLink( std::u16string_view rAppl
, std::u16string_view rTopic
,
1123 std::u16string_view rItem
, sal_uInt8 nMode
, size_t& rnDdePos
);
1125 /** Returns the connection data of the specified DDE link.
1126 @param nDdePos Index of the DDE link (does not include other links from link manager).
1127 @param rAppl (out-param) The application name.
1128 @param rTopic (out-param) The DDE topic.
1129 @param rItem (out-param) The DDE item.
1130 @return true = DDE link found, out-parameters valid. */
1131 bool GetDdeLinkData( size_t nDdePos
, OUString
& rAppl
, OUString
& rTopic
, OUString
& rItem
) const;
1132 /** Returns the link mode of the specified DDE link.
1133 @param nDdePos Index of the DDE link (does not include other links from link manager).
1134 @param rnMode (out-param) The link mode of the specified DDE link.
1135 @return true = DDE link found, rnMode valid. */
1136 bool GetDdeLinkMode( size_t nDdePos
, sal_uInt8
& rnMode
) const;
1137 /** Returns the result matrix of the specified DDE link.
1138 @param nDdePos Index of the DDE link (does not include other links from link manager).
1139 @return The result matrix, if the DDE link has been found, 0 otherwise. */
1140 SC_DLLPUBLIC
const ScMatrix
* GetDdeLinkResultMatrix( size_t nDdePos
) const;
1142 /** Tries to find a DDE link or creates a new, if not extant.
1143 @param pResults If not 0, sets the matrix as DDE link result matrix (also for existing links).
1144 @return true = DDE link found; false = Unpredictable error occurred, no DDE link created. */
1145 SC_DLLPUBLIC
bool CreateDdeLink( const OUString
& rAppl
, const OUString
& rTopic
, const OUString
& rItem
, sal_uInt8 nMode
, const ScMatrixRef
& pResults
);
1146 /** Sets a result matrix for the specified DDE link.
1147 @param nDdePos Index of the DDE link (does not include other links from link manager).
1148 @param pResults The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
1149 @return true = DDE link found and matrix set. */
1150 bool SetDdeLinkResultMatrix( size_t nDdePos
, const ScMatrixRef
& pResults
);
1152 SAL_RET_MAYBENULL SfxBindings
* GetViewBindings();
1153 ScDocShell
* GetDocumentShell() const { return mpShell
; }
1154 SC_DLLPUBLIC ScDrawLayer
* GetDrawLayer() { return mpDrawLayer
.get(); }
1155 SC_DLLPUBLIC
const ScDrawLayer
* GetDrawLayer() const { return mpDrawLayer
.get(); }
1156 SfxBroadcaster
* GetDrawBroadcaster(); // to avoid header
1157 void BeginDrawUndo();
1159 void BeginUnoRefUndo();
1160 bool HasUnoRefUndo() const { return ( pUnoRefUndoList
!= nullptr ); }
1162 std::unique_ptr
<ScUnoRefList
> EndUnoRefUndo(); // must be deleted by caller!
1163 sal_Int64
GetNewUnoId() { return ++nUnoObjectId
; }
1164 void AddUnoRefChange( sal_Int64 nId
, const ScRangeList
& rOldRanges
);
1166 static bool IsChart( const SdrObject
* pObject
);
1168 void UpdateChartRef( UpdateRefMode eUpdateRefMode
,
1169 SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
1170 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
,
1171 SCCOL nDx
, SCROW nDy
, SCTAB nDz
);
1172 //! only assigns the new RangeList, no ChartListener or the like
1173 void SetChartRangeList( std::u16string_view rChartName
,
1174 const ScRangeListRef
& rNewRangeListRef
);
1176 void StartAnimations( SCTAB nTab
);
1178 bool HasBackgroundDraw( SCTAB nTab
, const tools::Rectangle
& rMMRect
) const;
1179 bool HasAnyDraw( SCTAB nTab
, const tools::Rectangle
& rMMRect
) const;
1181 const ScSheetEvents
* GetSheetEvents( SCTAB nTab
) const;
1182 void SetSheetEvents( SCTAB nTab
, std::unique_ptr
<ScSheetEvents
> pNew
);
1183 bool HasSheetEventScript( SCTAB nTab
, ScSheetEventId nEvent
, bool bWithVbaEvents
= false ) const;
1184 bool HasAnySheetEventScript( ScSheetEventId nEvent
, bool bWithVbaEvents
= false ) const; // on any sheet
1186 bool HasAnyCalcNotification() const;
1187 bool HasCalcNotification( SCTAB nTab
) const;
1188 void SetCalcNotification( SCTAB nTab
);
1189 void ResetCalcNotifications();
1191 SC_DLLPUBLIC ScOutlineTable
* GetOutlineTable( SCTAB nTab
, bool bCreate
= false );
1192 bool SetOutlineTable( SCTAB nTab
, const ScOutlineTable
* pNewOutline
);
1194 void DoAutoOutline( SCCOL nStartCol
, SCROW nStartRow
,
1195 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
);
1197 bool DoSubTotals( SCTAB nTab
, ScSubTotalParam
& rParam
);
1198 void RemoveSubTotals( SCTAB nTab
, ScSubTotalParam
& rParam
);
1199 bool TestRemoveSubTotals( SCTAB nTab
, const ScSubTotalParam
& rParam
);
1200 bool HasSubTotalCells( const ScRange
& rRange
);
1202 SC_DLLPUBLIC
void EnsureTable( SCTAB nTab
);
1204 // return TRUE = number format is set
1205 SC_DLLPUBLIC
bool SetString( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const OUString
& rString
,
1206 const ScSetStringParam
* pParam
= nullptr );
1207 SC_DLLPUBLIC
bool SetString( const ScAddress
& rPos
, const OUString
& rString
,
1208 const ScSetStringParam
* pParam
= nullptr );
1211 * This method manages the lifecycle of the passed edit text object. When
1212 * the text is successfully inserted, the cell takes over the ownership of
1213 * the text object. If not, the text object gets deleted.
1215 * <p>The caller must ensure that the passed edit text object <i>uses the
1216 * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
1217 * This is very important.</p>
1219 SC_DLLPUBLIC
bool SetEditText( const ScAddress
& rPos
, std::unique_ptr
<EditTextObject
> pEditText
);
1220 void SetEditText( const ScAddress
& rPos
, const EditTextObject
& rEditText
, const SfxItemPool
* pEditPool
);
1221 SC_DLLPUBLIC
void SetEditText( const ScAddress
& rPos
, const OUString
& rStr
);
1222 SC_DLLPUBLIC SCROW
GetFirstEditTextRow( const ScRange
& rRange
) const;
1225 * Call this if you are not sure whether to put this as an edit text or a
1228 SC_DLLPUBLIC
void SetTextCell( const ScAddress
& rPos
, const OUString
& rStr
);
1229 void SetEmptyCell( const ScAddress
& rPos
);
1230 SC_DLLPUBLIC
void SetValue( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const double& rVal
);
1231 SC_DLLPUBLIC
void SetValue( const ScAddress
& rPos
, double fVal
);
1232 void SetValues( const ScAddress
& rPos
, const std::vector
<double>& rVals
);
1233 void SetError( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const FormulaError nError
);
1234 SC_DLLPUBLIC
void SetFormula( const ScAddress
& rPos
, const ScTokenArray
& rArray
);
1235 SC_DLLPUBLIC
void SetFormula( const ScAddress
& rPos
, const OUString
& rFormula
,
1236 formula::FormulaGrammar::Grammar eGram
);
1239 * Set formula cell, and transfer its ownership to the document. This call
1240 * attempts to group the passed formula cell with the adjacent cells or
1241 * cell groups if appropriate.
1243 * @return pCell if it was successfully inserted, NULL otherwise. pCell
1244 * is deleted automatically on failure to insert.
1246 SC_DLLPUBLIC ScFormulaCell
* SetFormulaCell( const ScAddress
& rPos
, ScFormulaCell
* pCell
);
1247 bool SetFormulaCells( const ScAddress
& rPos
, std::vector
<ScFormulaCell
*>& rCells
);
1250 * Check if there is at least one formula cell in specified range.
1252 bool HasFormulaCell( const ScRange
& rRange
) const;
1253 SC_DLLPUBLIC
void InsertMatrixFormula(SCCOL nCol1
, SCROW nRow1
,
1254 SCCOL nCol2
, SCROW nRow2
,
1255 const ScMarkData
& rMark
,
1256 const OUString
& rFormula
,
1257 const ScTokenArray
* p
= nullptr,
1258 const formula::FormulaGrammar::Grammar
= formula::FormulaGrammar::GRAM_DEFAULT
);
1259 SC_DLLPUBLIC
void InsertTableOp(const ScTabOpParam
& rParam
, // multi-operation
1260 SCCOL nCol1
, SCROW nRow1
,
1261 SCCOL nCol2
, SCROW nRow2
, const ScMarkData
& rMark
);
1263 SC_DLLPUBLIC OUString
GetString( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1264 ScInterpreterContext
* pContext
= nullptr ) const;
1265 SC_DLLPUBLIC OUString
GetString( const ScAddress
& rPos
,
1266 ScInterpreterContext
* pContext
= nullptr ) const;
1269 * Return a pointer to the double value stored in value cell.
1271 * @param rPos cell position
1273 * @return pointer to the double value stored in a numeric cell, or NULL
1274 * if the cell at specified position is not a numeric cell.
1276 SC_DLLPUBLIC
double* GetValueCell( const ScAddress
& rPos
);
1278 SC_DLLPUBLIC
svl::SharedStringPool
& GetSharedStringPool();
1279 const svl::SharedStringPool
& GetSharedStringPool() const;
1281 svl::SharedString
GetSharedString( const ScAddress
& rPos
) const;
1283 std::shared_ptr
<sc::FormulaGroupContext
>& GetFormulaGroupContext();
1284 void DiscardFormulaGroupContext();
1285 void BlockFormulaGroupContextDiscard( bool block
)
1286 { mbFormulaGroupCxtBlockDiscard
= block
; }
1288 // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
1289 SC_DLLPUBLIC OUString
GetInputString( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, bool bForceSystemLocale
= false ) const;
1290 FormulaError
GetStringForFormula( const ScAddress
& rPos
, OUString
& rString
);
1291 SC_DLLPUBLIC
double GetValue( const ScAddress
& rPos
) const;
1292 SC_DLLPUBLIC
double GetValue( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1293 SC_DLLPUBLIC
const EditTextObject
* GetEditText( const ScAddress
& rPos
) const;
1294 void RemoveEditTextCharAttribs( const ScAddress
& rPos
, const ScPatternAttr
& rAttr
);
1295 SC_DLLPUBLIC
double RoundValueAsShown( double fVal
, sal_uInt32 nFormat
, const ScInterpreterContext
* pContext
= nullptr ) const;
1296 SC_DLLPUBLIC sal_uInt32
GetNumberFormat( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1297 sal_uInt32
GetNumberFormat( const ScRange
& rRange
) const;
1298 SC_DLLPUBLIC sal_uInt32
GetNumberFormat( const ScInterpreterContext
& rContext
, const ScAddress
& ) const;
1299 SC_DLLPUBLIC
void SetNumberFormat( const ScAddress
& rPos
, sal_uInt32 nNumberFormat
);
1301 void GetNumberFormatInfo( const ScInterpreterContext
& rContext
, SvNumFormatType
& nType
, sal_uInt32
& nIndex
, const ScAddress
& rPos
) const;
1302 SC_DLLPUBLIC
const ScFormulaCell
* GetFormulaCell( const ScAddress
& rPos
) const;
1303 SC_DLLPUBLIC ScFormulaCell
* GetFormulaCell( const ScAddress
& rPos
);
1304 SC_DLLPUBLIC OUString
GetFormula( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1305 SC_DLLPUBLIC CellType
GetCellType( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1306 SC_DLLPUBLIC CellType
GetCellType( const ScAddress
& rPos
) const;
1308 SC_DLLPUBLIC
bool HasData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1309 SC_DLLPUBLIC
bool HasStringData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1310 SC_DLLPUBLIC
bool HasValueData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1311 SC_DLLPUBLIC
bool HasValueData( const ScAddress
& rPos
) const;
1312 bool HasStringCells( const ScRange
& rRange
) const;
1314 /** Returns true, if there is any data to create a selection list for rPos. */
1315 bool HasSelectionData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1316 bool HasValidationData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1319 * Check if the specified range contains either: 1) one non-empty cell, 2)
1320 * more than one non-empty cells, or 3) totally empty. In case the range
1321 * contains at least one non-empty cell, specify the position of the first
1324 sc::MultiDataCellState
HasMultipleDataCells( const ScRange
& rRange
) const;
1327 /** Returns sparkline at the address if it exists */
1328 SC_DLLPUBLIC
std::shared_ptr
<sc::Sparkline
> GetSparkline(ScAddress
const & rPosition
);
1329 SC_DLLPUBLIC
bool HasSparkline(ScAddress
const & rPosition
);
1330 SC_DLLPUBLIC
sc::Sparkline
* CreateSparkline(ScAddress
const & rPosition
, std::shared_ptr
<sc::SparklineGroup
> const& pSparklineGroup
);
1331 SC_DLLPUBLIC
sc::SparklineList
* GetSparklineList(SCTAB nTab
);
1332 SC_DLLPUBLIC
bool DeleteSparkline(ScAddress
const& rPosition
);
1335 * Returns true if the whole range covers one and the same sparkline
1336 * group and returns the group via out parameter
1338 SC_DLLPUBLIC
bool GetSparklineGroupInRange(ScRange
const& rRange
, std::shared_ptr
<sc::SparklineGroup
>& rGroup
);
1339 SC_DLLPUBLIC
bool HasOneSparklineGroup(ScRange
const& rRange
);
1340 SC_DLLPUBLIC
std::shared_ptr
<sc::SparklineGroup
> SearchSparklineGroup(tools::Guid
const& rGuid
);
1343 SC_DLLPUBLIC ScPostIt
* GetNote(const ScAddress
& rPos
);
1344 SC_DLLPUBLIC ScPostIt
* GetNote(SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1345 void SetNote(const ScAddress
& rPos
, std::unique_ptr
<ScPostIt
> pNote
);
1346 void SetNote(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, std::unique_ptr
<ScPostIt
> pNote
);
1347 SC_DLLPUBLIC
bool HasNote(const ScAddress
& rPos
) const;
1348 bool HasNote(SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1349 bool HasNote(SCTAB nTab
, SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
) const;
1350 SC_DLLPUBLIC
bool HasColNotes(SCCOL nCol
, SCTAB nTab
) const;
1351 SC_DLLPUBLIC
bool HasTabNotes(SCTAB nTab
) const;
1352 bool HasNotes() const;
1353 SC_DLLPUBLIC
std::unique_ptr
<ScPostIt
> ReleaseNote(const ScAddress
& rPos
);
1354 SC_DLLPUBLIC ScPostIt
* GetOrCreateNote(const ScAddress
& rPos
);
1355 SC_DLLPUBLIC ScPostIt
* CreateNote(const ScAddress
& rPos
);
1356 size_t GetNoteCount( SCTAB nTab
, SCCOL nCol
) const;
1359 * Ensure that all note objects have an associated sdr object. The export
1360 * code uses sdr objects to export note data.
1362 void CreateAllNoteCaptions();
1363 void ForgetNoteCaptions( const ScRangeList
& rRanges
, bool bPreserveData
);
1364 CommentCaptionState
GetAllNoteCaptionsState( const ScRangeList
& rRanges
);
1366 ScAddress
GetNotePosition( size_t nIndex
) const;
1367 ScAddress
GetNotePosition( size_t nIndex
, SCTAB nTab
) const;
1368 SCROW
GetNotePosition( SCTAB nTab
, SCCOL nCol
, size_t nIndex
) const;
1370 SC_DLLPUBLIC
void GetAllNoteEntries( std::vector
<sc::NoteEntry
>& rNotes
) const;
1371 SC_DLLPUBLIC
void GetAllNoteEntries( SCTAB nTab
, std::vector
<sc::NoteEntry
>& rNotes
) const;
1372 void GetNotesInRange( const ScRangeList
& rRange
, std::vector
<sc::NoteEntry
>& rNotes
) const;
1374 bool ContainsNotesInRange( const ScRangeList
& rRange
) const;
1376 SC_DLLPUBLIC
void SetDrawPageSize(SCTAB nTab
);
1378 bool IsMerged( const ScAddress
& rPos
) const;
1380 void ExtendMergeSel( SCCOL nStartCol
, SCROW nStartRow
,
1381 SCCOL
& rEndCol
, SCROW
& rEndRow
, const ScMarkData
& rMark
,
1382 bool bRefresh
= false );
1383 SC_DLLPUBLIC
bool ExtendMerge( SCCOL nStartCol
, SCROW nStartRow
,
1384 SCCOL
& rEndCol
, SCROW
& rEndRow
, SCTAB nTab
,
1385 bool bRefresh
= false );
1386 bool ExtendMerge( ScRange
& rRange
, bool bRefresh
= false );
1387 SC_DLLPUBLIC
void ExtendTotalMerge( ScRange
& rRange
) const;
1388 SC_DLLPUBLIC
void ExtendOverlapped( SCCOL
& rStartCol
, SCROW
& rStartRow
,
1389 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
) const;
1390 SC_DLLPUBLIC
void ExtendOverlapped( ScRange
& rRange
) const;
1392 bool RefreshAutoFilter( SCCOL nStartCol
, SCROW nStartRow
,
1393 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
);
1395 SC_DLLPUBLIC
void DoMergeContents( SCCOL nStartCol
, SCROW nStartRow
,
1396 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
);
1397 SC_DLLPUBLIC
void DoEmptyBlock( SCCOL nStartCol
, SCROW nStartRow
,
1398 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
);
1399 // without checking:
1400 SC_DLLPUBLIC
void DoMerge( SCCOL nStartCol
, SCROW nStartRow
,
1401 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
, bool bDeleteCaptions
= true );
1402 void RemoveMerge( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1404 // This also includes e.g. notes. Use IsEmptyData() for cell data only.
1405 bool IsBlockEmpty( SCCOL nStartCol
, SCROW nStartRow
,
1406 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
) const;
1407 bool IsNotesBlockEmpty( SCCOL nStartCol
, SCROW nStartRow
,
1408 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
) const;
1409 bool IsPrintEmpty( SCCOL nStartCol
, SCROW nStartRow
,
1410 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
,
1411 bool bLeftIsEmpty
= false,
1412 ScRange
* pLastRange
= nullptr,
1413 tools::Rectangle
* pLastMM
= nullptr ) const;
1415 void SkipOverlapped( SCCOL
& rCol
, SCROW
& rRow
, SCTAB nTab
) const;
1416 bool IsHorOverlapped( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1417 bool IsVerOverlapped( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1418 SCROW
* nStartRow
= nullptr, SCROW
* nEndRow
= nullptr ) const;
1420 SC_DLLPUBLIC
bool HasAttrib( SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
1421 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
, HasAttrFlags nMask
) const;
1422 SC_DLLPUBLIC
bool HasAttrib( const ScRange
& rRange
, HasAttrFlags nMask
) const;
1423 bool HasAttrib( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, HasAttrFlags nMask
,
1424 SCROW
* nStartRow
= nullptr, SCROW
* nEndRow
= nullptr ) const;
1426 SC_DLLPUBLIC
void GetBorderLines( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1427 const ::editeng::SvxBorderLine
** ppLeft
,
1428 const ::editeng::SvxBorderLine
** ppTop
,
1429 const ::editeng::SvxBorderLine
** ppRight
,
1430 const ::editeng::SvxBorderLine
** ppBottom
) const;
1432 void ResetChanged( const ScRange
& rRange
);
1434 void CheckVectorizationState();
1435 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext
& rCxt
);
1436 void SetDirty( const ScRange
&, bool bIncludeEmptyCells
);
1437 void SetTableOpDirty( const ScRange
& ); // for Interpreter TableOp
1438 void InterpretDirtyCells( const ScRangeList
& rRanges
);
1439 // Interprets cells that have NeedsInterpret(), i.e. the same like calling MaybeInterpret() on them.
1440 // Returns false if some couldn't be interpreted (i.e. they still have NeedsInterpret()).
1441 // Useful to ensure that the given cells will not need interpreting.
1442 bool InterpretCellsIfNeeded( const ScRangeList
& rRanges
);
1443 SC_DLLPUBLIC
void CalcAll();
1444 SC_DLLPUBLIC
void CalcAfterLoad( bool bStartListening
= true );
1449 * Re-compile formula cells with error.
1451 * @param nErrCode specified error code to match. Only those cells with
1452 * this error code will be re-compiled. If this value is
1453 * 0, cells with any error values will be re-compiled.
1455 * @return true if at least one cell is re-compiled, false if no cells are
1458 bool CompileErrorCells(FormulaError nErrCode
);
1460 ScAutoNameCache
* GetAutoNameCache() { return pAutoNameCache
.get(); }
1461 void SetPreviewFont( std::unique_ptr
<SfxItemSet
> pFontSet
);
1462 SfxItemSet
* GetPreviewFont() { return pPreviewFont
.get(); }
1463 SfxItemSet
* GetPreviewFont( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1464 const ScMarkData
& GetPreviewSelection() const { return maPreviewSelection
; }
1465 void SetPreviewSelection( const ScMarkData
& rSel
);
1466 ScStyleSheet
* GetPreviewCellStyle() { return pPreviewCellStyle
; }
1467 ScStyleSheet
* GetPreviewCellStyle( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
1468 void SetPreviewCellStyle( ScStyleSheet
* pStyle
) { pPreviewCellStyle
= pStyle
; }
1469 SC_DLLPUBLIC
void SetAutoNameCache( std::unique_ptr
<ScAutoNameCache
> pCache
);
1471 /** Creates a ScLookupCache cache for the range if it
1472 doesn't already exist. */
1473 ScLookupCache
& GetLookupCache( const ScRange
& rRange
, ScInterpreterContext
* pContext
);
1474 ScSortedRangeCache
& GetSortedRangeCache( const ScRange
& rRange
, const ScQueryParam
& param
,
1475 ScInterpreterContext
* pContext
, bool bNewSearchFunction
,
1476 sal_uInt8 nSortedBinarySearch
= 0x00 );
1477 /** Only ScLookupCache dtor uses RemoveLookupCache(), do
1478 not use elsewhere! */
1479 void RemoveLookupCache( ScLookupCache
& rCache
);
1480 void RemoveSortedRangeCache( ScSortedRangeCache
& rCache
);
1481 /** Zap all caches. */
1482 void ClearLookupCaches();
1484 // calculate automatically
1485 SC_DLLPUBLIC
void SetAutoCalc( bool bNewAutoCalc
);
1486 SC_DLLPUBLIC
bool GetAutoCalc() const { return bAutoCalc
; }
1487 // calculate automatically in/from/for ScDocShell disabled
1488 void SetAutoCalcShellDisabled( bool bNew
) { bAutoCalcShellDisabled
= bNew
; }
1489 bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled
; }
1490 // ForcedFormulas are to be calculated
1491 void SetForcedFormulaPending( bool bNew
) { bForcedFormulaPending
= bNew
; }
1492 bool IsForcedFormulaPending() const { return bForcedFormulaPending
; }
1493 // if CalcFormulaTree() is currently running
1494 bool IsCalculatingFormulaTree() const { return bCalculatingFormulaTree
; }
1495 /// If set, joining cells into shared formula groups will be delayed until reset again
1496 /// (RegroupFormulaCells() will be called as needed).
1497 void DelayFormulaGrouping( bool delay
);
1498 bool IsDelayedFormulaGrouping() const { return bool(pDelayedFormulaGrouping
); }
1499 /// To be used only by SharedFormulaUtil::joinFormulaCells().
1500 void AddDelayedFormulaGroupingCell( const ScFormulaCell
* cell
);
1501 /// If set, ScColumn::StartListeningFormulaCells() calls may be delayed using
1502 /// CanDelayStartListeningFormulaCells() until reset again, at which point the function will
1503 /// be called as necessary.
1504 void EnableDelayStartListeningFormulaCells( ScColumn
* column
, bool delay
);
1505 bool IsEnabledDelayStartListeningFormulaCells( ScColumn
* column
) const;
1506 /// If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed
1507 /// later. If false is returned, it needs to be done explicitly.
1508 bool CanDelayStartListeningFormulaCells( ScColumn
* column
, SCROW row1
, SCROW row2
);
1509 /// If set, cells will not delete their empty broadcasters, avoiding possible extensive mdds
1510 /// vector changes. Disabling delay will collect and delete all empty broadcasters.
1511 void EnableDelayDeletingBroadcasters(bool set
);
1512 bool IsDelayedDeletingBroadcasters() const { return bDelayedDeletingBroadcasters
; }
1514 FormulaError
GetErrCode( const ScAddress
& ) const;
1516 /** Shrink a range to only include data area.
1518 This is not the actually used area within the
1519 selection, but the bounds of the sheet's data area
1522 @returns TRUE if the area passed intersected the data
1523 area, FALSE if not, in which case the values
1524 obtained may be out of bounds, not in order or
1525 unmodified. TRUE does not mean that there
1526 actually is any data within the selection.
1528 bool ShrinkToDataArea( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
, SCCOL
& rEndCol
, SCROW
& rEndRow
) const;
1530 /** Shrink a range to only include used data area.
1533 Out parameter, true if area was shrunk, false if not.
1535 If TRUE, shrink only by columns, not rows.
1536 @param bStickyTopRow
1537 If TRUE, do not adjust the top row.
1538 @param bStickyLeftCol
1539 If TRUE, do not adjust the left column.
1540 @param pDataAreaExtras
1541 Consider additional area attributes like cell
1542 formatting, cell notes and draw objects. The
1543 possibly larger area than the actual cell
1544 content data area is returned within the
1547 @returns true if there is any data, false if not.
1549 bool ShrinkToUsedDataArea( bool& o_bShrunk
,
1550 SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
,
1551 SCCOL
& rEndCol
, SCROW
& rEndRow
, bool bColumnsOnly
,
1552 bool bStickyTopRow
= false, bool bStickyLeftCol
= false,
1553 ScDataAreaExtras
* pDataAreaExtras
= nullptr ) const;
1556 * Return the last non-empty row position in given columns that's no
1557 * greater than the initial last row position, or 0 if the columns are
1558 * empty. A negative value is returned if the given sheet or column
1559 * positions are invalid.
1561 * <p>It starts from the specified last row position, and finds the first
1562 * non-empty row position in the upward direction if the start row
1563 * position is empty.</p>
1565 SC_DLLPUBLIC SCROW
GetLastDataRow( SCTAB nTab
, SCCOL nCol1
, SCCOL nCol2
, SCROW nLastRow
) const;
1568 * Return the smallest area containing at least all contiguous cells
1569 * having data. This area is a square containing also empty cells. It may
1570 * shrink or extend the area given as input Flags as modifiers:
1572 * @param bIncludeOld when true, ensure that the returned area contains at
1573 * least the initial area even if the actual data area
1574 * is smaller than the initial area.
1576 * @param bOnlyDown when true, extend / shrink the data area only in a
1577 * downward direction i.e. only modify the end row
1580 SC_DLLPUBLIC
void GetDataArea( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
,
1581 SCCOL
& rEndCol
, SCROW
& rEndRow
,
1582 bool bIncludeOld
, bool bOnlyDown
) const;
1585 * Return the extended area containing at least all contiguous cells
1586 * having background color.
1588 SC_DLLPUBLIC
void GetBackColorArea( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
,
1589 SCCOL
& rEndCol
, SCROW
& rEndRow
) const;
1592 * Returns true if there is a non-empty subrange in the range given as input.
1593 * In that case it also modifies rRange to largest subrange that does not
1594 * have empty col/row inrange-segments in the beginning/end.
1595 * It returns false if rRange is completely empty and in this case rRange is
1598 bool GetDataAreaSubrange(ScRange
& rRange
) const;
1600 SC_DLLPUBLIC
bool GetCellArea( SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
) const;
1601 SC_DLLPUBLIC
bool GetTableArea( SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
,
1602 bool bCalcHiddens
= false) const;
1603 SC_DLLPUBLIC
bool GetPrintArea( SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
,
1604 bool bNotes
= true) const;
1605 SC_DLLPUBLIC
bool GetPrintAreaHor( SCTAB nTab
, SCROW nStartRow
, SCROW nEndRow
,
1606 SCCOL
& rEndCol
) const;
1607 SC_DLLPUBLIC
bool GetPrintAreaVer( SCTAB nTab
, SCCOL nStartCol
, SCCOL nEndCol
,
1608 SCROW
& rEndRow
, bool bNotes
) const;
1609 void InvalidateTableArea();
1611 /// Return the number of columns / rows that should be visible for the tiled rendering.
1612 SC_DLLPUBLIC
void GetTiledRenderingArea(SCTAB nTab
, SCCOL
& rEndCol
, SCROW
& rEndRow
) const;
1614 SC_DLLPUBLIC
bool GetDataStart( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
) const;
1617 * Find the maximum column position that contains printable data for the
1618 * specified row range. The final column position must be equal or less
1619 * than the initial value of rEndCol.
1621 void ExtendPrintArea( OutputDevice
* pDev
, SCTAB nTab
,
1622 SCCOL nStartCol
, SCROW nStartRow
,
1623 SCCOL
& rEndCol
, SCROW nEndRow
) const;
1624 SC_DLLPUBLIC
bool IsEmptyData(SCCOL nStartCol
, SCROW nStartRow
,
1625 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
) const;
1626 // I think this returns the number of empty cells starting from the given direction.
1627 SC_DLLPUBLIC SCSIZE
GetEmptyLinesInBlock( SCCOL nStartCol
, SCROW nStartRow
, SCTAB nStartTab
,
1628 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nEndTab
,
1631 void FindAreaPos( SCCOL
& rCol
, SCROW
& rRow
, SCTAB nTab
, ScMoveDirection eDirection
) const;
1632 SC_DLLPUBLIC
void GetNextPos( SCCOL
& rCol
, SCROW
& rRow
, SCTAB nTab
, SCCOL nMovX
, SCROW nMovY
,
1633 bool bMarked
, bool bUnprotected
, const ScMarkData
& rMark
,
1634 SCCOL nTabStartCol
= SC_TABSTART_NONE
) const;
1636 bool GetNextMarkedCell( SCCOL
& rCol
, SCROW
& rRow
, SCTAB nTab
,
1637 const ScMarkData
& rMark
);
1639 void LimitChartArea( SCTAB nTab
, SCCOL
& rStartCol
, SCROW
& rStartRow
,
1640 SCCOL
& rEndCol
, SCROW
& rEndRow
);
1641 void LimitChartIfAll( ScRangeListRef
& rRangeList
);
1643 bool InsertRow( SCCOL nStartCol
, SCTAB nStartTab
,
1644 SCCOL nEndCol
, SCTAB nEndTab
,
1645 SCROW nStartRow
, SCSIZE nSize
, ScDocument
* pRefUndoDoc
= nullptr,
1646 const ScMarkData
* pTabMark
= nullptr );
1647 SC_DLLPUBLIC
bool InsertRow( const ScRange
& rRange
);
1648 void DeleteRow( SCCOL nStartCol
, SCTAB nStartTab
,
1649 SCCOL nEndCol
, SCTAB nEndTab
,
1650 SCROW nStartRow
, SCSIZE nSize
,
1651 ScDocument
* pRefUndoDoc
= nullptr, bool* pUndoOutline
= nullptr,
1652 const ScMarkData
* pTabMark
= nullptr );
1653 SC_DLLPUBLIC
void DeleteRow( const ScRange
& rRange
);
1654 bool InsertCol( SCROW nStartRow
, SCTAB nStartTab
,
1655 SCROW nEndRow
, SCTAB nEndTab
,
1656 SCCOL nStartCol
, SCSIZE nSize
, ScDocument
* pRefUndoDoc
= nullptr,
1657 const ScMarkData
* pTabMark
= nullptr );
1658 SC_DLLPUBLIC
bool InsertCol( const ScRange
& rRange
);
1659 void DeleteCol( SCROW nStartRow
, SCTAB nStartTab
,
1660 SCROW nEndRow
, SCTAB nEndTab
,
1661 SCCOL nStartCol
, SCSIZE nSize
,
1662 ScDocument
* pRefUndoDoc
= nullptr, bool* pUndoOutline
= nullptr,
1663 const ScMarkData
* pTabMark
= nullptr );
1664 void DeleteCol( const ScRange
& rRange
);
1666 bool CanInsertRow( const ScRange
& rRange
) const;
1667 bool CanInsertCol( const ScRange
& rRange
) const;
1669 void FitBlock( const ScRange
& rOld
, const ScRange
& rNew
, bool bClear
= true );
1670 bool CanFitBlock( const ScRange
& rOld
, const ScRange
& rNew
);
1672 bool IsClipOrUndo() const { return bIsClip
|| bIsUndo
; }
1673 bool IsUndo() const { return bIsUndo
; }
1674 bool IsClipboard() const { return bIsClip
; }
1675 bool IsUndoEnabled() const { return mbUndoEnabled
; }
1676 SC_DLLPUBLIC
void EnableUndo( bool bVal
);
1677 bool IsFunctionAccess() const { return bIsFunctionAccess
; }
1679 bool IsAdjustHeightLocked() const { return nAdjustHeightLock
!= 0; }
1680 void LockAdjustHeight() { ++nAdjustHeightLock
; }
1681 SC_DLLPUBLIC
void UnlockAdjustHeight();
1682 bool IsExecuteLinkEnabled() const { return mbExecuteLinkEnabled
; }
1683 void EnableExecuteLink( bool bVal
) { mbExecuteLinkEnabled
= bVal
; }
1684 bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled
; }
1685 void EnableChangeReadOnly( bool bVal
) { mbChangeReadOnlyEnabled
= bVal
; }
1686 SC_DLLPUBLIC
bool IsUserInteractionEnabled() const { return mbUserInteractionEnabled
;}
1687 SC_DLLPUBLIC
void EnableUserInteraction( bool bVal
);
1688 SC_DLLPUBLIC sal_Int16
GetNamedRangesLockCount() const { return mnNamedRangesLockCount
; }
1689 void SetNamedRangesLockCount( sal_Int16 nCount
) { mnNamedRangesLockCount
= nCount
; }
1690 SC_DLLPUBLIC
void ResetClip( ScDocument
* pSourceDoc
, const ScMarkData
* pMarks
);
1691 SC_DLLPUBLIC
void ResetClip( ScDocument
* pSourceDoc
, SCTAB nTab
);
1692 void SetCutMode( bool bCut
);
1694 void SetClipArea( const ScRange
& rArea
, bool bCut
= false );
1696 SC_DLLPUBLIC
bool IsDocVisible() const { return bIsVisible
; }
1697 SC_DLLPUBLIC
void SetDocVisible( bool bSet
);
1699 bool HasOLEObjectsInArea( const ScRange
& rRange
, const ScMarkData
* pTabMark
= nullptr );
1701 void DeleteObjectsInArea( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1702 const ScMarkData
& rMark
, bool bAnchored
= false );
1703 void DeleteObjectsInSelection( const ScMarkData
& rMark
);
1705 SC_DLLPUBLIC
void DeleteArea( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
, const ScMarkData
& rMark
,
1706 InsertDeleteFlags nDelFlag
, bool bBroadcast
= true,
1707 sc::ColumnSpanSet
* pBroadcastSpans
= nullptr );
1709 SC_DLLPUBLIC
void DeleteAreaTab(SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1710 SCTAB nTab
, InsertDeleteFlags nDelFlag
);
1711 void DeleteAreaTab(const ScRange
& rRange
, InsertDeleteFlags nDelFlag
);
1713 SC_DLLPUBLIC
void CopyToClip( const ScClipParam
& rClipParam
, ScDocument
* pClipDoc
,
1714 const ScMarkData
* pMarks
, bool bKeepScenarioFlags
,
1715 bool bIncludeObjects
);
1718 * Copy only raw cell values to another document. Formula cells are
1719 * converted to raw cells. No formatting info are copied except for
1722 * @param rSrcRange source range in the source document
1723 * @param nDestTab table in the clip document to copy to.
1724 * @param rDestDoc document to copy to
1726 SC_DLLPUBLIC
void CopyStaticToDocument(const ScRange
& rSrcRange
, SCTAB nDestTab
, ScDocument
& rDestDoc
);
1729 * Copy only cell, nothing but cell to another document.
1731 * @param rSrcPos source cell position
1732 * @param rDestPos destination cell position
1733 * @param rDestDoc destination document
1735 void CopyCellToDocument( const ScAddress
& rSrcPos
, const ScAddress
& rDestPos
, ScDocument
& rDestDoc
);
1737 void CopyTabToClip( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1738 SCTAB nTab
, ScDocument
* pClipDoc
);
1740 SC_DLLPUBLIC
bool InitColumnBlockPosition( sc::ColumnBlockPosition
& rBlockPos
, SCTAB nTab
, SCCOL nCol
);
1742 void DeleteBeforeCopyFromClip( sc::CopyFromClipContext
& rCxt
, const ScMarkData
& rMark
,
1743 sc::ColumnSpanSet
& rBroadcastSpans
);
1745 SC_DLLPUBLIC
bool CopyOneCellFromClip(sc::CopyFromClipContext
& rCxt
, SCCOL nCol1
, SCROW nRow1
,
1746 SCCOL nCol2
, SCROW nRow2
);
1747 void CopyBlockFromClip( sc::CopyFromClipContext
& rCxt
, SCCOL nCol1
, SCROW nRow1
,
1748 SCCOL nCol2
, SCROW nRow2
, const ScMarkData
& rMark
,
1749 SCCOL nDx
, SCROW nDy
);
1751 * @return the number of non-filtered rows.
1753 SCROW
CopyNonFilteredFromClip(sc::CopyFromClipContext
& rCxt
, SCCOL nCol1
, SCROW nRow1
,
1754 SCCOL nCol2
, SCROW nRow2
, const ScMarkData
& rMark
, SCCOL nDx
,
1755 SCROW
& rClipStartRow
, SCROW nClipEndRow
);
1757 void StartListeningFromClip(
1758 sc::StartListeningContext
& rStartCxt
, sc::EndListeningContext
& rEndCxt
,
1759 SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
1760 void StartListeningFromClip( SCCOL nCol1
, SCROW nRow1
,
1761 SCCOL nCol2
, SCROW nRow2
,
1762 const ScMarkData
& rMark
, InsertDeleteFlags nInsFlag
);
1764 void SetDirtyFromClip( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1765 const ScMarkData
& rMark
, InsertDeleteFlags nInsFlag
,
1766 sc::ColumnSpanSet
& rBroadcastSpans
);
1769 * Paste data from a clipboard document into this document.
1771 * @param rDestRange destination range.
1772 * @param pClipDoc pointer to the clipboard document to copy data from.
1773 * @param bSkipEmptyCells if this flag is set, empty cells in the source
1774 * range in the clipboard document will not overwrite
1775 * the target destination cells.
1776 * @param pDestRanges If pDestRanges is given it overrides rDestRange, where
1777 * rDestRange becomes the overall encompassing range.
1779 SC_DLLPUBLIC
void CopyFromClip(
1780 const ScRange
& rDestRange
, const ScMarkData
& rMark
, InsertDeleteFlags nInsFlag
,
1781 ScDocument
* pRefUndoDoc
, ScDocument
* pClipDoc
,
1782 bool bResetCut
= true, bool bAsLink
= false,
1783 bool bIncludeFiltered
= true, bool bSkipEmptyCells
= false,
1784 const ScRangeList
* pDestRanges
= nullptr );
1786 void CopyMultiRangeFromClip(const ScAddress
& rDestPos
, const ScMarkData
& rMark
,
1787 InsertDeleteFlags nInsFlag
, ScDocument
* pClipDoc
,
1788 bool bResetCut
= true, bool bAsLink
= false,
1789 bool bIncludeFiltered
= true,
1790 bool bSkipAttrForEmpty
= false);
1792 void GetClipArea(SCCOL
& nClipX
, SCROW
& nClipY
, bool bIncludeFiltered
);
1793 void GetClipStart(SCCOL
& nClipX
, SCROW
& nClipY
);
1795 bool HasClipFilteredRows();
1797 bool IsClipboardSource() const;
1799 SC_DLLPUBLIC
void TransposeClip(ScDocument
* pTransClip
, InsertDeleteFlags nFlags
, bool bAsLink
,
1800 bool bIncludeFiltered
);
1802 ScClipParam
& GetClipParam();
1803 void SetClipParam(const ScClipParam
& rParam
);
1805 /** To be called at the clipboard document when closing a document that is
1806 the current clipboard source to decouple things from the originating
1807 document. Done in ScDocument dtor after determining
1808 IsClipboardSource().
1810 void ClosingClipboardSource();
1812 void MixDocument( const ScRange
& rRange
, ScPasteFunc nFunction
, bool bSkipEmpty
,
1813 ScDocument
& rSrcDoc
);
1815 void FillTab( const ScRange
& rSrcArea
, const ScMarkData
& rMark
,
1816 InsertDeleteFlags nFlags
, ScPasteFunc nFunction
,
1817 bool bSkipEmpty
, bool bAsLink
);
1818 void FillTabMarked( SCTAB nSrcTab
, const ScMarkData
& rMark
,
1819 InsertDeleteFlags nFlags
, ScPasteFunc nFunction
,
1820 bool bSkipEmpty
, bool bAsLink
);
1822 void TransliterateText( const ScMarkData
& rMultiMark
, TransliterationFlags nType
);
1824 SC_DLLPUBLIC
void InitUndo( const ScDocument
& rSrcDoc
, SCTAB nTab1
, SCTAB nTab2
,
1825 bool bColInfo
= false, bool bRowInfo
= false );
1826 void AddUndoTab( SCTAB nTab1
, SCTAB nTab2
,
1827 bool bColInfo
= false, bool bRowInfo
= false );
1828 SC_DLLPUBLIC
void InitUndoSelected( const ScDocument
& rSrcDoc
, const ScMarkData
& rTabSelection
,
1829 bool bColInfo
= false, bool bRowInfo
= false );
1831 // don't use anymore:
1832 void CopyToDocument(SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
1833 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
,
1834 InsertDeleteFlags nFlags
, bool bMarked
, ScDocument
& rDestDoc
,
1835 const ScMarkData
* pMarks
= nullptr, bool bColRowFlags
= true);
1836 void UndoToDocument(SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
1837 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
,
1838 InsertDeleteFlags nFlags
, bool bMarked
, ScDocument
& rDestDoc
);
1840 SC_DLLPUBLIC
void CopyToDocument(const ScRange
& rRange
,
1841 InsertDeleteFlags nFlags
, bool bMarked
, ScDocument
& rDestDoc
,
1842 const ScMarkData
* pMarks
= nullptr, bool bColRowFlags
= true);
1843 void UndoToDocument(const ScRange
& rRange
,
1844 InsertDeleteFlags nFlags
, bool bMarked
, ScDocument
& rDestDoc
);
1846 void CopyScenario( SCTAB nSrcTab
, SCTAB nDestTab
, bool bNewScenario
= false );
1847 bool TestCopyScenario( SCTAB nSrcTab
, SCTAB nDestTab
) const;
1848 void MarkScenario(SCTAB nSrcTab
, SCTAB nDestTab
,
1849 ScMarkData
& rDestMark
, bool bResetMark
= true,
1850 ScScenarioFlags nNeededBits
= ScScenarioFlags::NONE
) const;
1851 bool HasScenarioRange( SCTAB nTab
, const ScRange
& rRange
) const;
1852 SC_DLLPUBLIC
const ScRangeList
* GetScenarioRanges( SCTAB nTab
) const;
1854 SC_DLLPUBLIC
void CopyUpdated( ScDocument
* pPosDoc
, ScDocument
* pDestDoc
);
1856 void UpdateReference( sc::RefUpdateContext
& rCxt
, ScDocument
*
1857 pUndoDoc
= nullptr, bool bIncludeDraw
= true,
1858 bool bUpdateNoteCaptionPos
= true );
1860 * @param pClipDoc original clipboard doc, i.e. non-transposed
1861 * This clip doc is used to check references pointing to cut cells.
1863 SC_DLLPUBLIC
void UpdateTranspose( const ScAddress
& rDestPos
, ScDocument
* pClipDoc
,
1864 const ScMarkData
& rMark
, ScDocument
* pUndoDoc
);
1866 void UpdateGrow( const ScRange
& rArea
, SCCOL nGrowX
, SCROW nGrowY
);
1868 SC_DLLPUBLIC
void Fill( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
1869 ScProgress
* pProgress
, const ScMarkData
& rMark
,
1870 sal_uInt64 nFillCount
, FillDir eFillDir
= FILL_TO_BOTTOM
,
1871 FillCmd eFillCmd
= FILL_LINEAR
, FillDateCmd eFillDateCmd
= FILL_DAY
,
1872 double nStepValue
= 1.0, double nMaxValue
= 1E307
);
1873 OUString
GetAutoFillPreview( const ScRange
& rSource
, SCCOL nEndX
, SCROW nEndY
);
1875 bool GetSelectionFunction( ScSubTotalFunc eFunc
,
1876 const ScAddress
& rCursor
, const ScMarkData
& rMark
,
1879 SC_DLLPUBLIC
const SfxPoolItem
* GetAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt16 nWhich
) const;
1880 template<class T
> const T
* GetAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, TypedWhichId
<T
> nWhich
) const
1882 return static_cast<const T
*>(GetAttr(nCol
, nRow
, nTab
, sal_uInt16(nWhich
)));
1884 SC_DLLPUBLIC
const SfxPoolItem
* GetAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt16 nWhich
,
1885 SCROW
& nStartRow
, SCROW
& nEndRow
) const;
1886 template<class T
> const T
* GetAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, TypedWhichId
<T
> nWhich
,
1887 SCROW
& nStartRow
, SCROW
& nEndRow
) const
1889 return static_cast<const T
*>(GetAttr(nCol
, nRow
, nTab
, sal_uInt16(nWhich
), nStartRow
, nEndRow
));
1891 SC_DLLPUBLIC
const SfxPoolItem
* GetAttr( const ScAddress
& rPos
, sal_uInt16 nWhich
) const;
1892 template<class T
> const T
* GetAttr( const ScAddress
& rPos
, TypedWhichId
<T
> nWhich
) const
1894 return static_cast<const T
*>(GetAttr(rPos
, sal_uInt16(nWhich
)));
1896 SC_DLLPUBLIC
const ScPatternAttr
* GetPattern( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1897 SC_DLLPUBLIC
const ScPatternAttr
* GetPattern( const ScAddress
& rPos
) const;
1898 SC_DLLPUBLIC
const ScPatternAttr
* GetMostUsedPattern( SCCOL nCol
, SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
1899 const ScPatternAttr
* GetSelectionPattern( const ScMarkData
& rMark
);
1900 std::unique_ptr
<ScPatternAttr
> CreateSelectionPattern( const ScMarkData
& rMark
, bool bDeep
= true );
1901 SC_DLLPUBLIC
void AddCondFormatData( const ScRangeList
& rRange
, SCTAB nTab
, sal_uInt32 nIndex
);
1902 void RemoveCondFormatData( const ScRangeList
& rRange
, SCTAB nTab
, sal_uInt32 nIndex
);
1904 SC_DLLPUBLIC ScConditionalFormat
* GetCondFormat( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1905 // pCell is an optimization, must point to rPos
1906 SC_DLLPUBLIC
const SfxItemSet
* GetCondResult( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1907 ScRefCellValue
* pCell
= nullptr ) const;
1908 const SfxItemSet
* GetCondResult( ScRefCellValue
& rCell
, const ScAddress
& rPos
,
1909 const ScConditionalFormatList
& rList
,
1910 const ScCondFormatIndexes
& rIndex
) const;
1911 const SfxPoolItem
* GetEffItem( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt16 nWhich
) const;
1912 template<class T
> const T
* GetEffItem( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, TypedWhichId
<T
> nWhich
) const
1914 return static_cast<const T
*>(GetEffItem(nCol
, nRow
, nTab
, sal_uInt16(nWhich
)));
1917 SC_DLLPUBLIC
const css::uno::Reference
< css::i18n::XBreakIterator
>& GetBreakIterator();
1918 bool HasStringWeakCharacters( const OUString
& rString
);
1919 SC_DLLPUBLIC SvtScriptType
GetStringScriptType( const OUString
& rString
);
1920 // pCell is an optimization, must point to rPos
1921 SC_DLLPUBLIC SvtScriptType
GetCellScriptType( const ScAddress
& rPos
, sal_uInt32 nNumberFormat
,
1922 const ScRefCellValue
* pCell
= nullptr );
1923 // pCell is an optimization, must point to nCol,nRow,nTab
1924 SC_DLLPUBLIC SvtScriptType
GetScriptType( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1925 const ScRefCellValue
* pCell
= nullptr );
1926 SvtScriptType
GetRangeScriptType( sc::ColumnBlockPosition
& rBlockPos
, const ScAddress
& rPos
, SCROW nLength
);
1927 SvtScriptType
GetRangeScriptType( const ScRangeList
& rRanges
);
1929 bool HasDetectiveOperations() const;
1930 void AddDetectiveOperation( const ScDetOpData
& rData
);
1931 void ClearDetectiveOperations();
1932 ScDetOpList
* GetDetOpList() const { return pDetOpList
.get(); }
1933 void SetDetOpList(std::unique_ptr
<ScDetOpList
> pNew
);
1935 bool HasDetectiveObjects(SCTAB nTab
) const;
1937 void GetSelectionFrame( const ScMarkData
& rMark
,
1938 SvxBoxItem
& rLineOuter
,
1939 SvxBoxInfoItem
& rLineInner
);
1940 void ApplySelectionFrame(const ScMarkData
& rMark
,
1941 const SvxBoxItem
& rLineOuter
,
1942 const SvxBoxInfoItem
* pLineInner
);
1943 void ApplyFrameAreaTab(const ScRange
& rRange
,
1944 const SvxBoxItem
& rLineOuter
,
1945 const SvxBoxInfoItem
& rLineInner
);
1947 void ClearSelectionItems( const sal_uInt16
* pWhich
, const ScMarkData
& rMark
);
1948 void ChangeSelectionIndent( bool bIncrement
, const ScMarkData
& rMark
);
1950 SC_DLLPUBLIC sal_uInt32
AddCondFormat( std::unique_ptr
<ScConditionalFormat
> pNew
, SCTAB nTab
);
1951 void DeleteConditionalFormat( sal_uLong nIndex
, SCTAB nTab
);
1953 void SetCondFormList( ScConditionalFormatList
* pList
, SCTAB nTab
);
1954 SC_DLLPUBLIC sal_uInt32
AddValidationEntry( const ScValidationData
& rNew
);
1955 SC_DLLPUBLIC
const ScValidationData
* GetValidationEntry( sal_uInt32 nIndex
) const;
1957 SC_DLLPUBLIC ScConditionalFormatList
* GetCondFormList( SCTAB nTab
) const;
1959 const ScValidationDataList
* GetValidationList() const { return pValidationList
.get();}
1960 ScValidationDataList
* GetValidationList() { return pValidationList
.get();}
1962 SC_DLLPUBLIC
void ApplyAttr( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1963 const SfxPoolItem
& rAttr
);
1964 SC_DLLPUBLIC
void ApplyPattern( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1965 const ScPatternAttr
& rAttr
);
1966 SC_DLLPUBLIC
void ApplyPatternArea( SCCOL nStartCol
, SCROW nStartRow
,
1967 SCCOL nEndCol
, SCROW nEndRow
,
1968 const ScMarkData
& rMark
, const ScPatternAttr
& rAttr
,
1969 ScEditDataArray
* pDataArray
= nullptr,
1970 bool* const pIsChanged
= nullptr );
1971 SC_DLLPUBLIC
void ApplyPatternAreaTab( SCCOL nStartCol
, SCROW nStartRow
,
1972 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
,
1973 const ScPatternAttr
& rAttr
);
1975 SC_DLLPUBLIC
void ApplyPatternIfNumberformatIncompatible( const ScRange
& rRange
,
1976 const ScMarkData
& rMark
,
1977 const ScPatternAttr
& rPattern
,
1978 SvNumFormatType nNewType
);
1980 void ApplyStyle( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
1981 const ScStyleSheet
& rStyle
);
1982 void ApplyStyleArea( SCCOL nStartCol
, SCROW nStartRow
,
1983 SCCOL nEndCol
, SCROW nEndRow
,
1984 const ScMarkData
& rMark
, const ScStyleSheet
& rStyle
);
1985 SC_DLLPUBLIC
void ApplyStyleAreaTab( SCCOL nStartCol
, SCROW nStartRow
,
1986 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
,
1987 const ScStyleSheet
& rStyle
);
1989 SC_DLLPUBLIC
void ApplySelectionStyle( const ScStyleSheet
& rStyle
, const ScMarkData
& rMark
);
1990 void ApplySelectionLineStyle( const ScMarkData
& rMark
,
1991 const ::editeng::SvxBorderLine
* pLine
, bool bColorOnly
);
1993 const ScStyleSheet
* GetStyle( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
1994 const ScStyleSheet
* GetSelectionStyle( const ScMarkData
& rMark
) const;
1996 void StyleSheetChanged( const SfxStyleSheetBase
* pStyleSheet
, bool bRemoved
,
1998 double nPPTX
, double nPPTY
,
1999 const Fraction
& rZoomX
, const Fraction
& rZoomY
);
2001 bool IsStyleSheetUsed( const ScStyleSheet
& rStyle
) const;
2003 SC_DLLPUBLIC
bool ApplyFlagsTab( SCCOL nStartCol
, SCROW nStartRow
,
2004 SCCOL nEndCol
, SCROW nEndRow
,
2005 SCTAB nTab
, ScMF nFlags
);
2006 SC_DLLPUBLIC
bool RemoveFlagsTab( SCCOL nStartCol
, SCROW nStartRow
,
2007 SCCOL nEndCol
, SCROW nEndRow
,
2008 SCTAB nTab
, ScMF nFlags
);
2010 SC_DLLPUBLIC
void SetPattern( const ScAddress
&, const ScPatternAttr
& rAttr
);
2011 SC_DLLPUBLIC
void SetPattern( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const CellAttributeHolder
& rHolder
);
2012 SC_DLLPUBLIC
void SetPattern( const ScAddress
& rPos
, const CellAttributeHolder
& rHolder
);
2014 void AutoFormat( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
2015 sal_uInt16 nFormatNo
, const ScMarkData
& rMark
);
2016 void GetAutoFormatData( SCTAB nTab
, SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
2017 ScAutoFormatData
& rData
);
2018 bool SearchAndReplace( const SvxSearchItem
& rSearchItem
,
2019 SCCOL
& rCol
, SCROW
& rRow
, SCTAB
& rTab
,
2020 const ScMarkData
& rMark
, ScRangeList
& rMatchedRanges
,
2021 OUString
& rUndoStr
, ScDocument
* pUndoDoc
, bool& bMatchedRangesWereClamped
);
2022 static bool IsEmptyCellSearch( const SvxSearchItem
& rSearchItem
);
2024 // determine Col/Row of subsequent calls
2025 // (e.g. not found from the beginning, or subsequent tables)
2026 // meaning of explanation in "()" was already unclear in German
2027 void GetSearchAndReplaceStart( const SvxSearchItem
& rSearchItem
,
2028 SCCOL
& rCol
, SCROW
& rRow
);
2031 bool Solver( SCCOL nFCol
, SCROW nFRow
, SCTAB nFTab
,
2032 SCCOL nVCol
, SCROW nVRow
, SCTAB nVTab
,
2033 const OUString
& sValStr
, double& nX
);
2034 const ScGoalSeekSettings
& GetGoalSeekSettings() { return maGoalSeekSettings
; }
2035 void SetGoalSeekSettings(const ScGoalSeekSettings
& rNewSettings
) { maGoalSeekSettings
= rNewSettings
; }
2037 SC_DLLPUBLIC
void ApplySelectionPattern( const ScPatternAttr
& rAttr
, const ScMarkData
& rMark
,
2038 ScEditDataArray
* pDataArray
= nullptr, bool* pIsChanged
= nullptr );
2039 SC_DLLPUBLIC
void DeleteSelection( InsertDeleteFlags nDelFlag
, const ScMarkData
& rMark
, bool bBroadcast
= true );
2040 void DeleteSelectionTab( SCTAB nTab
, InsertDeleteFlags nDelFlag
, const ScMarkData
& rMark
);
2042 SC_DLLPUBLIC
void SetColWidth( SCCOL nCol
, SCTAB nTab
, sal_uInt16 nNewWidth
);
2043 SC_DLLPUBLIC
void SetColWidthOnly( SCCOL nCol
, SCTAB nTab
, sal_uInt16 nNewWidth
);
2044 SC_DLLPUBLIC
void SetRowHeight( SCROW nRow
, SCTAB nTab
, sal_uInt16 nNewHeight
);
2045 SC_DLLPUBLIC
void SetRowHeightRange( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
,
2046 sal_uInt16 nNewHeight
);
2048 SC_DLLPUBLIC
void SetRowHeightOnly( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
,
2049 sal_uInt16 nNewHeight
);
2050 SC_DLLPUBLIC
void SetManualHeight( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bManual
);
2052 SC_DLLPUBLIC sal_uInt16
GetColWidth( SCCOL nCol
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
2053 SC_DLLPUBLIC
tools::Long
GetColWidth( SCCOL nStartCol
, SCCOL nEndCol
, SCTAB nTab
) const;
2054 SC_DLLPUBLIC sal_uInt16
GetRowHeight( SCROW nRow
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
2055 SC_DLLPUBLIC sal_uInt16
GetRowHeight( SCROW nRow
, SCTAB nTab
, SCROW
* pStartRow
, SCROW
* pEndRow
, bool bHiddenAsZero
= true ) const;
2056 SC_DLLPUBLIC
tools::Long
GetRowHeight( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
2059 * Given the height i.e. total vertical distance from the top of the sheet
2060 * grid, return the first visible row whose top position is below the
2063 SCROW
GetRowForHeight( SCTAB nTab
, tools::Long nHeight
) const;
2064 tools::Long
GetScaledRowHeight( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, double fScale
) const;
2065 SC_DLLPUBLIC
tools::Long
GetColOffset( SCCOL nCol
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
2066 SC_DLLPUBLIC
tools::Long
GetRowOffset( SCROW nRow
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
2068 SC_DLLPUBLIC sal_uInt16
GetOriginalWidth( SCCOL nCol
, SCTAB nTab
) const;
2069 SC_DLLPUBLIC sal_uInt16
GetOriginalHeight( SCROW nRow
, SCTAB nTab
) const;
2071 sal_uInt16
GetCommonWidth( SCCOL nEndCol
, SCTAB nTab
) const;
2073 SCROW
GetHiddenRowCount( SCROW nRow
, SCTAB nTab
) const;
2075 sal_uInt16
GetOptimalColWidth( SCCOL nCol
, SCTAB nTab
, OutputDevice
* pDev
,
2076 double nPPTX
, double nPPTY
,
2077 const Fraction
& rZoomX
, const Fraction
& rZoomY
,
2079 const ScMarkData
* pMarkData
= nullptr,
2080 const ScColWidthParam
* pParam
= nullptr );
2082 SC_DLLPUBLIC
bool SetOptimalHeight( sc::RowHeightContext
& rCxt
, SCROW nStartRow
,
2083 SCROW nEndRow
, SCTAB nTab
, bool bApi
);
2085 void UpdateAllRowHeights( sc::RowHeightContext
& rCxt
, const ScMarkData
* pTabMark
);
2087 tools::Long
GetNeededSize( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
2089 double nPPTX
, double nPPTY
,
2090 const Fraction
& rZoomX
, const Fraction
& rZoomY
,
2091 bool bWidth
, bool bTotalSize
= false,
2092 bool bInPrintTwips
= false );
2094 SC_DLLPUBLIC
void ShowCol(SCCOL nCol
, SCTAB nTab
, bool bShow
);
2095 SC_DLLPUBLIC
void ShowRow(SCROW nRow
, SCTAB nTab
, bool bShow
);
2096 SC_DLLPUBLIC
void ShowRows(SCROW nRow1
, SCROW nRow2
, SCTAB nTab
, bool bShow
);
2097 SC_DLLPUBLIC
void SetRowFlags( SCROW nRow
, SCTAB nTab
, CRFlags nNewFlags
);
2098 SC_DLLPUBLIC
void SetRowFlags( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, CRFlags nNewFlags
);
2100 SC_DLLPUBLIC CRFlags
GetColFlags( SCCOL nCol
, SCTAB nTab
) const;
2101 SC_DLLPUBLIC CRFlags
GetRowFlags( SCROW nRow
, SCTAB nTab
) const;
2103 SC_DLLPUBLIC
void GetAllRowBreaks(std::set
<SCROW
>& rBreaks
, SCTAB nTab
, bool bPage
, bool bManual
) const;
2104 SC_DLLPUBLIC
void GetAllColBreaks(std::set
<SCCOL
>& rBreaks
, SCTAB nTab
, bool bPage
, bool bManual
) const;
2105 SC_DLLPUBLIC ScBreakType
HasRowBreak(SCROW nRow
, SCTAB nTab
) const;
2106 SC_DLLPUBLIC ScBreakType
HasColBreak(SCCOL nCol
, SCTAB nTab
) const;
2107 SC_DLLPUBLIC
void SetRowBreak(SCROW nRow
, SCTAB nTab
, bool bPage
, bool bManual
);
2108 SC_DLLPUBLIC
void SetColBreak(SCCOL nCol
, SCTAB nTab
, bool bPage
, bool bManual
);
2109 void RemoveRowBreak(SCROW nRow
, SCTAB nTab
, bool bPage
, bool bManual
);
2110 void RemoveColBreak(SCCOL nCol
, SCTAB nTab
, bool bPage
, bool bManual
);
2112 css::sheet::TablePageBreakData
> GetRowBreakData(SCTAB nTab
) const;
2114 SC_DLLPUBLIC
bool RowHidden(SCROW nRow
, SCTAB nTab
, SCROW
* pFirstRow
= nullptr, SCROW
* pLastRow
= nullptr) const;
2115 SC_DLLPUBLIC
bool HasHiddenRows(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2116 SC_DLLPUBLIC
bool ColHidden(SCCOL nCol
, SCTAB nTab
, SCCOL
* pFirstCol
= nullptr, SCCOL
* pLastCol
= nullptr) const;
2117 SC_DLLPUBLIC
void SetRowHidden(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bHidden
);
2118 SC_DLLPUBLIC
void SetColHidden(SCCOL nStartCol
, SCCOL nEndCol
, SCTAB nTab
, bool bHidden
);
2119 SC_DLLPUBLIC SCROW
FirstVisibleRow(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2120 SC_DLLPUBLIC SCROW
LastVisibleRow(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2121 SCROW
CountVisibleRows(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2123 SC_DLLPUBLIC
bool RowFiltered(SCROW nRow
, SCTAB nTab
, SCROW
* pFirstRow
= nullptr, SCROW
* pLastRow
= nullptr) const;
2124 bool HasFilteredRows(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2125 bool ColFiltered(SCCOL nCol
, SCTAB nTab
) const;
2126 SC_DLLPUBLIC
void SetRowFiltered(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bFiltered
);
2127 SCROW
FirstNonFilteredRow(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2128 SCROW
LastNonFilteredRow(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2129 SCROW
CountNonFilteredRows(SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
) const;
2131 SC_DLLPUBLIC
bool IsManualRowHeight(SCROW nRow
, SCTAB nTab
) const;
2133 bool HasUniformRowHeight( SCTAB nTab
, SCROW nRow1
, SCROW nRow2
) const;
2136 * Write all column row flags to table's flag data, because not all column
2137 * row attributes are stored in the flag data members. This is necessary
2140 void SyncColRowFlags();
2142 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
2143 SC_DLLPUBLIC SCROW
GetLastFlaggedRow( SCTAB nTab
) const;
2145 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
2146 SCCOL
GetLastChangedColFlagsWidth( SCTAB nTab
) const;
2147 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
2148 SCROW
GetLastChangedRowFlagsWidth( SCTAB nTab
) const;
2150 SCCOL
GetNextDifferentChangedColFlagsWidth( SCTAB nTab
, SCCOL nStart
) const;
2152 SCROW
GetNextDifferentChangedRowFlagsWidth( SCTAB nTab
, SCROW nStart
) const;
2154 // returns whether to export a Default style for this col or not
2155 // nDefault is set to one position in the current row where the Default style is
2156 void GetColDefault( SCTAB nTab
, SCCOL nCol
, SCROW nLastRow
, SCROW
& nDefault
);
2158 bool UpdateOutlineCol( SCCOL nStartCol
, SCCOL nEndCol
, SCTAB nTab
, bool bShow
);
2159 bool UpdateOutlineRow( SCROW nStartRow
, SCROW nEndRow
, SCTAB nTab
, bool bShow
);
2161 void StripHidden( SCCOL
& rX1
, SCROW
& rY1
, SCCOL
& rX2
, SCROW
& rY2
, SCTAB nTab
);
2162 void ExtendHidden( SCCOL
& rX1
, SCROW
& rY1
, SCCOL
& rX2
, SCROW
& rY2
, SCTAB nTab
);
2164 SC_DLLPUBLIC ScDocumentPool
* GetPool();
2165 SC_DLLPUBLIC ScStyleSheetPool
* GetStyleSheetPool() const;
2166 void GetUnprotectedCells( ScRangeList
& rRange
, SCTAB nTab
) const;
2169 SC_DLLPUBLIC OUString
GetPageStyle( SCTAB nTab
) const;
2170 SC_DLLPUBLIC
void SetPageStyle( SCTAB nTab
, const OUString
& rName
);
2171 Size
GetPageSize( SCTAB nTab
) const;
2172 void SetPageSize( SCTAB nTab
, const Size
& rSize
);
2173 void SetRepeatArea( SCTAB nTab
, SCCOL nStartCol
, SCCOL nEndCol
, SCROW nStartRow
, SCROW nEndRow
);
2174 void InvalidatePageBreaks(SCTAB nTab
);
2175 void UpdatePageBreaks( SCTAB nTab
, const ScRange
* pUserArea
= nullptr );
2176 void RemoveManualBreaks( SCTAB nTab
);
2177 bool HasManualBreaks( SCTAB nTab
) const;
2179 bool IsPageStyleInUse( std::u16string_view rStrPageStyle
, SCTAB
* pInTab
);
2180 bool RemovePageStyleInUse( std::u16string_view rStrPageStyle
);
2181 bool RenamePageStyleInUse( std::u16string_view rOld
, const OUString
& rNew
);
2182 void ModifyStyleSheet( SfxStyleSheetBase
& rPageStyle
,
2183 const SfxItemSet
& rChanges
);
2185 void PageStyleModified( SCTAB nTab
, const OUString
& rNewName
);
2187 SC_DLLPUBLIC
bool NeedPageResetAfterTab( SCTAB nTab
) const;
2189 // Was stored in PageStyle previously. Now it exists for every table:
2190 SC_DLLPUBLIC
bool HasPrintRange();
2191 SC_DLLPUBLIC sal_uInt16
GetPrintRangeCount( SCTAB nTab
);
2192 SC_DLLPUBLIC
const ScRange
* GetPrintRange( SCTAB nTab
, sal_uInt16 nPos
);
2193 SC_DLLPUBLIC
std::optional
<ScRange
> GetRepeatColRange( SCTAB nTab
);
2194 SC_DLLPUBLIC
std::optional
<ScRange
> GetRepeatRowRange( SCTAB nTab
);
2195 /** Returns true, if the specified sheet is always printed. */
2196 bool IsPrintEntireSheet( SCTAB nTab
) const;
2198 /** Removes all print ranges. */
2199 SC_DLLPUBLIC
void ClearPrintRanges( SCTAB nTab
);
2200 /** Adds a new print ranges. */
2201 SC_DLLPUBLIC
void AddPrintRange( SCTAB nTab
, const ScRange
& rNew
);
2202 // Removes all named ranges used for print ranges in a given tab
2203 SC_DLLPUBLIC
void ClearPrintNamedRanges( SCTAB nTab
);
2204 /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */
2205 SC_DLLPUBLIC
void SetPrintEntireSheet( SCTAB nTab
);
2206 SC_DLLPUBLIC
void SetRepeatColRange( SCTAB nTab
, std::optional
<ScRange
> oNew
);
2207 SC_DLLPUBLIC
void SetRepeatRowRange( SCTAB nTab
, std::optional
<ScRange
> oNew
);
2208 std::unique_ptr
<ScPrintRangeSaver
> CreatePrintRangeSaver() const;
2209 void RestorePrintRanges( const ScPrintRangeSaver
& rSaver
);
2211 SC_DLLPUBLIC
tools::Rectangle
GetMMRect( SCCOL nStartCol
, SCROW nStartRow
,
2212 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nTab
, bool bHiddenAsZero
= true ) const;
2213 SC_DLLPUBLIC ScRange
GetRange( SCTAB nTab
, const tools::Rectangle
& rMMRect
, bool bHiddenAsZero
= true ) const;
2215 SC_DLLPUBLIC
void CopyStdStylesFrom( const ScDocument
& rSrcDoc
);
2217 static sal_uInt16
GetSrcVersion() { return nSrcVer
; }
2219 void SetSrcCharSet( rtl_TextEncoding eNew
) { eSrcSet
= eNew
; }
2220 void UpdateFontCharSet();
2222 void FillInfo( ScTableInfo
& rTabInfo
, SCCOL nCol1
, SCROW nRow1
,
2223 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab
, double fColScale
,
2224 double fRowScale
, bool bPageMode
, bool bFormulaMode
,
2225 const ScMarkData
* pMarkData
= nullptr );
2227 SC_DLLPUBLIC SvNumberFormatter
* GetFormatTable() const;
2229 /** Sort a range of data. */
2230 void Sort( SCTAB nTab
, const ScSortParam
& rSortParam
,
2231 bool bKeepQuery
, bool bUpdateRefs
,
2232 ScProgress
* pProgress
, sc::ReorderParam
* pUndo
);
2234 void Reorder( const sc::ReorderParam
& rParam
);
2236 void PrepareQuery( SCTAB nTab
, ScQueryParam
& rQueryParam
);
2237 SCSIZE
Query( SCTAB nTab
, const ScQueryParam
& rQueryParam
, bool bKeepSub
);
2238 SC_DLLPUBLIC
bool CreateQueryParam( const ScRange
& rRange
, ScQueryParam
& rQueryParam
);
2239 OUString
GetUpperCellString(SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
2242 * Get a list of unique strings to use in filtering criteria. The string
2243 * values are sorted, and there are no duplicate values in the list. The
2244 * data range to use to populate the filter entries is inferred from the
2245 * database range that contains the specified cell position.
2247 void GetFilterEntries( SCCOL nCol
, SCROW nRow
,
2248 SCTAB nTab
, ScFilterEntries
& rFilterEntries
);
2250 SC_DLLPUBLIC
void GetFilterEntriesArea( SCCOL nCol
, SCROW nStartRow
, SCROW nEndRow
,
2251 SCTAB nTab
, bool bCaseSens
,
2252 ScFilterEntries
& rFilterEntries
);
2254 void GetDataEntries( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
2255 std::vector
<ScTypedStrData
>& rStrings
, bool bValidation
= false );
2256 void GetFormulaEntries( ScTypedCaseStrSet
& rStrings
);
2258 bool HasAutoFilter( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
2259 void GetFilterSelCount( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, SCSIZE
& nSelected
, SCSIZE
& nTotal
);
2261 SC_DLLPUBLIC
bool HasColHeader( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
2263 SC_DLLPUBLIC
bool HasRowHeader( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
2266 SfxPrinter
* GetPrinter( bool bCreateIfNotExist
= true );
2267 void SetPrinter( VclPtr
<SfxPrinter
> const & pNewPrinter
);
2268 VirtualDevice
* GetVirtualDevice_100th_mm();
2269 SC_DLLPUBLIC OutputDevice
* GetRefDevice(bool bForceVirtDev
= false); // WYSIWYG: Printer, otherwise VirtualDevice...
2271 bool GetNextSpellingCell( SCCOL
& nCol
, SCROW
& nRow
, SCTAB nTab
,
2272 bool bInSel
, const ScMarkData
& rMark
) const;
2274 void ReplaceStyle( const SvxSearchItem
& rSearchItem
,
2275 SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
2276 const ScMarkData
& rMark
);
2278 void InvalidateTextWidth( std::u16string_view rStyleName
);
2279 void InvalidateTextWidth( SCTAB nTab
);
2280 void InvalidateTextWidth( const ScAddress
* pAdrFrom
, const ScAddress
* pAdrTo
, bool bNumFormatChanged
);
2282 bool IdleCalcTextWidth();
2284 void RepaintRange( const ScRange
& rRange
);
2285 void RepaintRange( const ScRangeList
& rRange
);
2287 bool IsIdleEnabled() const { return mbIdleEnabled
; }
2288 void EnableIdle(bool bDo
) { mbIdleEnabled
= bDo
; }
2290 bool IsDetectiveDirty() const { return bDetectiveDirty
; }
2291 void SetDetectiveDirty(bool bSet
) { bDetectiveDirty
= bSet
; }
2293 bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck
; }
2294 void SetLinkFormulaNeedingCheck(bool bSet
) { bLinkFormulaNeedingCheck
= bSet
; }
2295 /** Check token array and set link check if ocDde/ocWebservice is contained. */
2296 SC_DLLPUBLIC
void CheckLinkFormulaNeedingCheck( const ScTokenArray
& rCode
);
2298 void SetRangeOverflowType(ErrCode nType
) { nRangeOverflowType
= nType
; }
2299 bool HasRangeOverflow() const { return nRangeOverflowType
!= ERRCODE_NONE
; }
2300 SC_DLLPUBLIC
const ErrCode
& GetRangeOverflowType() const { return nRangeOverflowType
; }
2302 // for broadcasting/listening
2303 void SetInsertingFromOtherDoc( bool bVal
) { bInsertingFromOtherDoc
= bVal
; }
2304 bool IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc
; }
2305 void SetLoadingMedium( bool bVal
);
2306 SC_DLLPUBLIC
void SetImportingXML( bool bVal
);
2307 bool IsImportingXML() const { return bImportingXML
; }
2308 bool IsCalcingAfterLoad() const { return bCalcingAfterLoad
; }
2309 void SetNoListening( bool bVal
) { bNoListening
= bVal
; }
2310 bool GetNoListening() const { return bNoListening
; }
2311 ScBroadcastAreaSlotMachine
* GetBASM() const { return pBASM
.get(); }
2313 SC_DLLPUBLIC ScChartListenerCollection
* GetChartListenerCollection() const { return pChartListenerCollection
.get(); }
2314 void SetChartListenerCollection( std::unique_ptr
<ScChartListenerCollection
>,
2315 bool bSetChartRangeLists
);
2316 void UpdateChart( const OUString
& rName
);
2317 void RestoreChartListener( const OUString
& rName
);
2318 SC_DLLPUBLIC
void UpdateChartListenerCollection();
2319 bool IsChartListenerCollectionNeedsUpdate() const { return bChartListenerCollectionNeedsUpdate
; }
2320 void SetChartListenerCollectionNeedsUpdate( bool bFlg
) { bChartListenerCollectionNeedsUpdate
= bFlg
; }
2321 void AddOLEObjectToCollection(const OUString
& rName
);
2323 ScChangeViewSettings
* GetChangeViewSettings() const { return pChangeViewSettings
.get(); }
2324 SC_DLLPUBLIC
void SetChangeViewSettings(const ScChangeViewSettings
& rNew
);
2326 const std::shared_ptr
<SvxForbiddenCharactersTable
>& GetForbiddenCharacters() const;
2327 void SetForbiddenCharacters(const std::shared_ptr
<SvxForbiddenCharactersTable
>& rNew
);
2329 CharCompressType
GetAsianCompression() const;
2330 bool IsValidAsianCompression() const;
2331 void SetAsianCompression(CharCompressType nNew
);
2333 bool GetAsianKerning() const;
2334 bool IsValidAsianKerning() const;
2335 void SetAsianKerning(bool bNew
);
2336 void ApplyAsianEditSettings(ScEditEngineDefaulter
& rEngine
);
2338 EEHorizontalTextDirection
GetEditTextDirection(SCTAB nTab
) const; // EEHorizontalTextDirection values
2340 SC_DLLPUBLIC ScLkUpdMode
GetLinkMode() const { return eLinkMode
;}
2341 void SetLinkMode( ScLkUpdMode nSet
) { eLinkMode
= nSet
;}
2343 SC_DLLPUBLIC ScMacroManager
* GetMacroManager();
2345 void FillMatrix( ScMatrix
& rMat
, SCTAB nTab
, SCCOL nCol1
,
2346 SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
2347 svl::SharedStringPool
* pPool
= nullptr) const;
2350 * Set an array of numerical formula results to a group of contiguous
2353 * @param rTopPos position of the top formula cell of a group.
2354 * @param pResults array of numeric results.
2355 * @param nLen length of numeric results.
2357 void SC_DLLPUBLIC
SetFormulaResults( const ScAddress
& rTopPos
, const double* pResults
, size_t nLen
);
2359 void CalculateInColumnInThread( ScInterpreterContext
& rContext
, const ScRange
& rCalcRange
, unsigned nThisThread
, unsigned nThreadsTotal
);
2360 void HandleStuffAfterParallelCalculation( SCCOL nColStart
, SCCOL nColEnd
, SCROW nRow
, size_t nLen
, SCTAB nTab
, ScInterpreter
* pInterpreter
);
2363 * Transfer a series of contiguous cell values from specified position to
2364 * the passed container. The specified segment will become empty after the
2367 void TransferCellValuesTo( const ScAddress
& rTopPos
, size_t nLen
, sc::CellValues
& rDest
);
2368 void CopyCellValuesFrom( const ScAddress
& rTopPos
, const sc::CellValues
& rSrc
);
2370 std::set
<Color
> GetDocColors();
2371 sc::IconSetBitmapMap
& GetIconSetBitmapMap();
2373 std::set
<SCCOL
> QueryColumnsWithFormulaCells( SCTAB nTab
) const;
2376 * Check the integrity of the internal table state. Useful from testing
2377 * code. It throws an exception upon first failure.
2379 * Feel free to add more checks as needed.
2381 void CheckIntegrity( SCTAB nTab
) const;
2384 ScDocument(const ScDocument
& r
) = delete;
2386 void FindMaxRotCol( SCTAB nTab
, RowInfo
* pRowInfo
, SCSIZE nArrCount
,
2387 SCCOL nX1
, SCCOL nX2
) const;
2389 sal_uInt16
RowDifferences( SCROW nThisRow
, SCTAB nThisTab
,
2390 ScDocument
& rOtherDoc
,
2391 SCROW nOtherRow
, SCTAB nOtherTab
,
2392 SCCOL nMaxCol
, const SCCOLROW
* pOtherCols
);
2393 sal_uInt16
ColDifferences( SCCOL nThisCol
, SCTAB nThisTab
,
2394 ScDocument
& rOtherDoc
,
2395 SCCOL nOtherCol
, SCTAB nOtherTab
,
2396 SCROW nMaxRow
, const SCCOLROW
* pOtherRows
);
2397 void FindOrder( SCCOLROW
* pOtherRows
, SCCOLROW nThisEndRow
, SCCOLROW nOtherEndRow
,
2399 ScDocument
& rOtherDoc
, SCTAB nThisTab
, SCTAB nOtherTab
,
2400 SCCOLROW nEndCol
, const SCCOLROW
* pTranslate
,
2401 ScProgress
* pProgress
, sal_uInt64 nProAdd
);
2403 DECL_LINK(TrackTimeHdl
, Timer
*, void);
2405 /** Adjust a range to available sheets.
2407 Used to start and stop listening on a sane range. Both o_rRange and
2408 o_bEntirelyOutOfBounds are set only if needed and don't have to be
2409 initialized by the caller.
2411 @param o_bEntirelyOutOfBounds
2412 <TRUE/> if both sheets in the range point outside the
2413 available sheet range, in which case no adjustment is done and
2414 o_rRange is not modified.
2416 @return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds
2418 <FALSE/> if rRange was within the available sheets.
2420 bool LimitRangeToAvailableSheets( const ScRange
& rRange
, ScRange
& o_rRange
,
2421 bool& o_bEntirelyOutOfBounds
) const;
2424 void StartListeningArea( const ScRange
& rRange
, bool bGroupListening
, SvtListener
* pListener
);
2426 void EndListeningArea( const ScRange
& rRange
, bool bGroupListening
, SvtListener
* pListener
);
2427 /** Broadcast wrapper, calls
2428 rHint.GetCell()->Broadcast() and AreaBroadcast()
2432 void Broadcast( const ScHint
& rHint
);
2434 void BroadcastCells( const ScRange
& rRange
, SfxHintId nHint
, bool bBroadcastSingleBroadcasters
= true );
2436 /// only area, no cell broadcast
2437 void AreaBroadcast( const ScHint
& rHint
);
2438 void DelBroadcastAreasInRange( const ScRange
& rRange
);
2439 void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode
,
2440 const ScRange
& rRange
,
2441 SCCOL nDx
, SCROW nDy
, SCTAB nDz
);
2443 void StartListeningCell( const ScAddress
& rAddress
,
2444 SvtListener
* pListener
);
2445 void EndListeningCell( const ScAddress
& rAddress
,
2446 SvtListener
* pListener
);
2448 void StartListeningCell( sc::StartListeningContext
& rCxt
, const ScAddress
& rPos
, SvtListener
& rListener
);
2449 void EndListeningCell( sc::EndListeningContext
& rCxt
, const ScAddress
& rPos
, SvtListener
& rListener
);
2451 void EndListeningFormulaCells( std::vector
<ScFormulaCell
*>& rCells
);
2453 sc::BroadcasterState
GetBroadcasterState() const;
2455 void PutInFormulaTree( ScFormulaCell
* pCell
);
2456 void RemoveFromFormulaTree( ScFormulaCell
* pCell
);
2459 * Calculate formula cells that are on the formula tree either partially,
2462 * @param bOnlyForced when true, it only calculates those formula cells
2463 * that are marked "recalc forced".
2464 * @param bProgressBar whether or not to use progress bar.
2465 * @param bSetAllDirty when true, it marks all formula cells currently on
2466 * the formula tree dirty, which forces all of them to
2467 * be recalculated. When false, only those cells
2468 * that are marked dirty prior to this call get
2471 SC_DLLPUBLIC
void CalcFormulaTree( bool bOnlyForced
= false, bool bProgressBar
= true, bool bSetAllDirty
= true );
2472 void ClearFormulaTree();
2473 void AppendToFormulaTrack( ScFormulaCell
* pCell
);
2474 void RemoveFromFormulaTrack( ScFormulaCell
* pCell
);
2475 void TrackFormulas( SfxHintId nHintId
= SfxHintId::ScDataChanged
);
2476 void SetTrackFormulasPending() { mbTrackFormulasPending
= true; }
2477 bool IsTrackFormulasPending() const { return mbTrackFormulasPending
; }
2478 void FinalTrackFormulas( SfxHintId nHintId
);
2479 bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas
; }
2480 inline bool IsInFormulaTree( const ScFormulaCell
* pCell
) const;
2481 inline bool IsInFormulaTrack( const ScFormulaCell
* pCell
) const;
2482 HardRecalcState
GetHardRecalcState() const { return eHardRecalcState
; }
2483 void SetHardRecalcState( HardRecalcState eVal
) { eHardRecalcState
= eVal
; }
2484 void StartAllListeners();
2485 void StartNeededListeners();
2486 void StartNeededListeners( const std::shared_ptr
<const sc::ColumnSet
>& rpColSet
);
2487 SC_DLLPUBLIC
void StartAllListeners( const ScRange
& rRange
);
2489 void SetForcedFormulas( bool bVal
) { bHasForcedFormulas
= bVal
; }
2490 sal_uInt64
GetFormulaCodeInTree() const { return nFormulaCodeInTree
; }
2492 bool IsInInterpreter() const { return nInterpretLevel
!= 0; }
2494 void IncInterpretLevel()
2496 assert(!IsThreadedGroupCalcInProgress());
2497 if ( nInterpretLevel
< USHRT_MAX
)
2500 void DecInterpretLevel()
2502 assert(!IsThreadedGroupCalcInProgress());
2503 if ( nInterpretLevel
)
2506 sal_uInt16
GetMacroInterpretLevel() const { return nMacroInterpretLevel
; }
2507 void IncMacroInterpretLevel()
2509 assert(!IsThreadedGroupCalcInProgress());
2510 if ( nMacroInterpretLevel
< USHRT_MAX
)
2511 nMacroInterpretLevel
++;
2513 void DecMacroInterpretLevel()
2515 assert(!IsThreadedGroupCalcInProgress());
2516 if ( nMacroInterpretLevel
)
2517 nMacroInterpretLevel
--;
2519 bool IsInInterpreterTableOp() const { return nInterpreterTableOpLevel
!= 0; }
2520 void IncInterpreterTableOpLevel()
2522 if ( nInterpreterTableOpLevel
< USHRT_MAX
)
2523 nInterpreterTableOpLevel
++;
2525 void DecInterpreterTableOpLevel()
2527 if ( nInterpreterTableOpLevel
)
2528 nInterpreterTableOpLevel
--;
2531 // add a formula to be remembered for TableOp broadcasts
2532 void AddTableOpFormulaCell( ScFormulaCell
* );
2533 void InvalidateLastTableOpParams() { aLastTableOpParams
.bValid
= false; }
2534 ScRecursionHelper
& GetRecursionHelper();
2535 bool IsInDtorClear() const { return bInDtorClear
; }
2536 void SetExpandRefs( bool bVal
);
2537 bool IsExpandRefs() const { return bExpandRefs
; }
2539 sal_uInt64
GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount
; }
2540 void IncXMLImportedFormulaCount( sal_uInt64 nVal
)
2542 if ( nXMLImportedFormulaCount
+ nVal
> nXMLImportedFormulaCount
)
2543 nXMLImportedFormulaCount
+= nVal
;
2545 void DecXMLImportedFormulaCount( sal_uInt64 nVal
)
2547 if ( nVal
<= nXMLImportedFormulaCount
)
2548 nXMLImportedFormulaCount
-= nVal
;
2550 nXMLImportedFormulaCount
= 0;
2553 void StartTrackTimer();
2555 void CompileDBFormula();
2556 void CompileColRowNameFormula();
2558 /** Maximum string length of a column, e.g. for dBase export.
2559 @return String length in octets (!) of the destination encoding. In
2560 case of non-octet encodings (e.g. UCS2) the length in code
2561 points times sizeof(sal_Unicode) is returned. */
2562 sal_Int32
GetMaxStringLen( SCTAB nTab
, SCCOL nCol
,
2563 SCROW nRowStart
, SCROW nRowEnd
,
2564 rtl_TextEncoding eCharSet
) const;
2565 /** Maximum string length of numerical cells of a column, e.g. for dBase export.
2566 @return String length in characters (!) including the decimal
2567 separator, and the decimal precision needed. */
2568 sal_Int32
GetMaxNumberStringLen( sal_uInt16
& nPrecision
,
2569 SCTAB nTab
, SCCOL nCol
,
2570 SCROW nRowStart
, SCROW nRowEnd
) const;
2572 void KeyInput(); // TimerDelays etc.
2574 ScChangeTrack
* GetChangeTrack() const { return pChangeTrack
.get(); }
2576 //! only for import filter, deletes any existing ChangeTrack via
2577 //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
2578 SC_DLLPUBLIC
void SetChangeTrack( std::unique_ptr
<ScChangeTrack
> pTrack
);
2580 void StartChangeTracking();
2581 void EndChangeTracking();
2583 SC_DLLPUBLIC
void CompareDocument( ScDocument
& rOtherDoc
);
2585 void AddUnoObject( SfxListener
& rObject
);
2586 void RemoveUnoObject( SfxListener
& rObject
);
2587 void BroadcastUno( const SfxHint
&rHint
);
2588 void AddUnoListenerCall( const css::uno::Reference
<
2589 css::util::XModifyListener
>& rListener
,
2590 const css::lang::EventObject
& rEvent
);
2592 void SetInLinkUpdate(bool bSet
); // TableLink or AreaLink
2593 bool IsInLinkUpdate() const; // including DdeLink
2595 SC_DLLPUBLIC SfxItemPool
* GetEditPool() const;
2596 SC_DLLPUBLIC SfxItemPool
* GetEnginePool() const;
2597 SC_DLLPUBLIC ScFieldEditEngine
& GetEditEngine();
2598 SC_DLLPUBLIC ScNoteEditEngine
& GetNoteEngine();
2600 std::unique_ptr
<EditTextObject
> CreateSharedStringTextObject( const svl::SharedString
& rSS
);
2602 std::unique_ptr
<ScRefreshTimerControl
> const & GetRefreshTimerControlAddress() const
2603 { return pRefreshTimerControl
; }
2605 void SetPastingDrawFromOtherDoc( bool bVal
)
2606 { bPastingDrawFromOtherDoc
= bVal
; }
2607 bool PastingDrawFromOtherDoc() const
2608 { return bPastingDrawFromOtherDoc
; }
2610 /// an ID unique to each document instance
2611 sal_uInt32
GetDocumentID() const;
2613 void InvalidateStyleSheetUsage() { bStyleSheetUsageInvalid
= true; }
2614 void SC_DLLPUBLIC
GetSortParam( ScSortParam
& rParam
, SCTAB nTab
);
2615 void SC_DLLPUBLIC
SetSortParam( const ScSortParam
& rParam
, SCTAB nTab
);
2617 void SetVbaEventProcessor( const css::uno::Reference
< css::script::vba::XVBAEventProcessor
>& rxVbaEvents
)
2618 { mxVbaEvents
= rxVbaEvents
; }
2619 const css::uno::Reference
< css::script::vba::XVBAEventProcessor
>& GetVbaEventProcessor() const { return mxVbaEvents
; }
2621 /** Should only be GRAM_PODF or GRAM_ODFF. */
2622 void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar
);
2623 formula::FormulaGrammar::Grammar
GetStorageGrammar() const { return eStorageGrammar
; }
2625 SC_DLLPUBLIC ScUndoManager
* GetUndoManager();
2626 bool IsInVBAMode() const;
2627 ScRowBreakIterator
* GetRowBreakIterator(SCTAB nTab
) const;
2629 void AddSubTotalCell(ScFormulaCell
* pCell
);
2630 void RemoveSubTotalCell(ScFormulaCell
* pCell
);
2631 void SetSubTotalCellsDirty(const ScRange
& rDirtyRange
);
2633 sal_uInt16
GetTextWidth( const ScAddress
& rPos
) const;
2635 SvtScriptType
GetScriptType( const ScAddress
& rPos
) const;
2636 void SetScriptType( const ScAddress
& rPos
, SvtScriptType nType
);
2637 void UpdateScriptTypes( const ScAddress
& rPos
, SCCOL nColSize
, SCROW nRowSize
);
2640 * Make specified formula cells non-grouped.
2642 * @param nTab sheet index
2643 * @param nCol column index
2644 * @param rRows list of row indices at which formula cells are to be
2645 * unshared. This call sorts the passed row indices and
2646 * removes duplicates, which is why the caller must pass it
2649 void UnshareFormulaCells( SCTAB nTab
, SCCOL nCol
, std::vector
<SCROW
>& rRows
);
2650 void RegroupFormulaCells( SCTAB nTab
, SCCOL nCol
);
2651 SC_DLLPUBLIC
void RegroupFormulaCells( const ScRange
& range
);
2653 formula::FormulaTokenRef
ResolveStaticReference( const ScAddress
& rPos
);
2654 formula::FormulaTokenRef
ResolveStaticReference( const ScRange
& rRange
);
2656 formula::VectorRefArray
FetchVectorRefArray( const ScAddress
& rPos
, SCROW nLength
);
2657 bool HandleRefArrayForParallelism( const ScAddress
& rPos
, SCROW nLength
,
2658 const ScFormulaCellGroupRef
& mxGroup
, ScAddress
* pDirtiedAddress
);
2660 void AssertNoInterpretNeeded( const ScAddress
& rPos
, SCROW nLength
);
2664 * Call this before any operations that might trigger one or more formula
2665 * cells to get calculated.
2667 void PrepareFormulaCalc();
2670 * Make sure all of the formula cells in the specified range have been
2671 * fully calculated. This method only re-calculates those formula cells
2672 * that have been flagged dirty. In case of formula-groups, this calculates
2673 * only the dirty subspans along with the dependents in the same way
2676 * @param rRange range in which to potentially calculate the formula
2678 * @param bSkipRunning flag to skip evaluation of formula-cells that are
2679 * marked as already being evaluated.
2680 * @return true if at least one formula-cell in the specified range was dirty
2681 * else returns false.
2683 SC_DLLPUBLIC
bool EnsureFormulaCellResults( const ScRange
& rRange
, bool bSkipRunning
= false );
2685 SvtBroadcaster
* GetBroadcaster( const ScAddress
& rPos
);
2686 const SvtBroadcaster
* GetBroadcaster( const ScAddress
& rPos
) const;
2687 void DeleteBroadcasters( sc::ColumnBlockPosition
& rBlockPos
, const ScAddress
& rTopPos
, SCROW nLength
);
2689 std::optional
<sc::ColumnIterator
> GetColumnIterator( SCTAB nTab
, SCCOL nCol
, SCROW nRow1
, SCROW nRow2
) const;
2690 void CreateColumnIfNotExists( SCTAB nTab
, SCCOL nCol
);
2692 SC_DLLPUBLIC
void StoreTabToCache(SCTAB nTab
, SvStream
& rStrm
) const;
2693 SC_DLLPUBLIC
void RestoreTabFromCache(SCTAB nTab
, SvStream
& rStream
);
2695 #if DUMP_COLUMN_STORAGE
2696 SC_DLLPUBLIC
void DumpColumnStorage( SCTAB nTab
, SCCOL nCol
) const;
2699 SC_DLLPUBLIC
void SetCalcConfig( const ScCalcConfig
& rConfig
);
2700 const ScCalcConfig
& GetCalcConfig() const { return maCalcConfig
; }
2701 void ConvertFormulaToValue( const ScRange
& rRange
, sc::TableValues
* pUndo
);
2702 void SwapNonEmpty( sc::TableValues
& rValues
);
2703 void finalizeOutlineImport();
2705 // Returns the given column range, first allocating all the columns if necessary.
2706 SC_DLLPUBLIC ScColumnsRange
GetWritableColumnsRange(SCTAB nTab
, SCCOL nColBegin
, SCCOL nColEnd
);
2707 // Returns a column range, clamped to the allocated columns.
2708 SC_DLLPUBLIC ScColumnsRange
GetAllocatedColumnsRange(SCTAB nTab
, SCCOL nColBegin
, SCCOL nColEnd
) const;
2709 // Returns the given range, without any adjustments. One of the variants above may return
2710 // a smaller range (better performance) if the use case is known.
2711 SC_DLLPUBLIC ScColumnsRange
GetColumnsRange(SCTAB nTab
, SCCOL nColBegin
, SCCOL nColEnd
) const;
2713 bool IsInDocShellRecalc() const { return mbDocShellRecalc
; }
2714 void SetDocShellRecalc(bool bSet
) { mbDocShellRecalc
= bSet
; }
2716 bool IsInLayoutStrings() const { return mbLayoutStrings
; }
2717 void SetLayoutStrings(bool bSet
) { mbLayoutStrings
= bSet
; }
2720 * Serializes the specified sheet's geometry data.
2722 * @param nTab is the index of the sheet to operate on.
2723 * @param bColumns - if true it dumps the data for columns, else it does for rows.
2724 * @param eGeomType indicates the type of data to be dumped for rows/columns.
2725 * @return the serialization of the specified sheet's geometry data as an OString.
2727 OString
dumpSheetGeomData(SCTAB nTab
, bool bColumns
, SheetGeomType eGeomType
);
2729 SCCOL
GetLOKFreezeCol(SCTAB nTab
) const;
2730 SCROW
GetLOKFreezeRow(SCTAB nTab
) const;
2731 bool SetLOKFreezeCol(SCCOL nFreezeCol
, SCTAB nTab
);
2732 bool SetLOKFreezeRow(SCROW nFreezeRow
, SCTAB nTab
);
2737 * Use this class as a locale variable to merge number formatter from
2738 * another document, and set NULL pointer to pFormatExchangeList when
2741 class NumFmtMergeHandler
2744 explicit NumFmtMergeHandler(ScDocument
& rDoc
, const ScDocument
& rSrcDoc
);
2745 ~NumFmtMergeHandler();
2751 void MergeNumberFormatter(const ScDocument
& rSrcDoc
);
2753 void ImplCreateOptions(); // Suggestion: switch to on-demand?
2754 void ImplDeleteOptions();
2756 SC_DLLPUBLIC
bool DrawGetPrintArea( ScRange
& rRange
, bool bSetHor
, bool bSetVer
) const;
2758 void UpdateDrawPrinter();
2759 void UpdateDrawLanguages();
2760 SC_DLLPUBLIC
void InitClipPtrs( ScDocument
* pSourceDoc
);
2762 void LoadDdeLinks(SvStream
& rStream
);
2763 void SaveDdeLinks(SvStream
& rStream
) const;
2765 void DeleteAreaLinksOnTab( SCTAB nTab
);
2766 void UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode
,
2767 const ScRange
& r
, SCCOL nDx
, SCROW nDy
, SCTAB nDz
);
2769 void CopyRangeNamesToClip(ScDocument
* pClipDoc
, const ScRange
& rClipRange
, const ScMarkData
* pMarks
);
2771 bool HasPartOfMerged( const ScRange
& rRange
);
2774 SC_DLLPUBLIC ScTable
* FetchTable( SCTAB nTab
);
2775 const ScTable
* FetchTable( SCTAB nTab
) const;
2777 ScRefCellValue
GetRefCellValue( const ScAddress
& rPos
);
2779 ScRefCellValue
GetRefCellValue( const ScAddress
& rPos
, sc::ColumnBlockPosition
& rBlockPos
);
2781 std::map
< SCTAB
, ScSortParam
> mSheetSortParams
;
2783 SCSIZE
GetPatternCount( SCTAB nTab
, SCCOL nCol
) const;
2784 SCSIZE
GetPatternCount( SCTAB nTab
, SCCOL nCol
, SCROW nRow1
, SCROW nRow2
) const;
2785 void ReservePatternCount( SCTAB nTab
, SCCOL nCol
, SCSIZE nReserve
);
2787 void SharePooledResources( const ScDocument
* pSrcDoc
);
2789 void EndListeningIntersectedGroup(
2790 sc::EndListeningContext
& rCxt
, const ScAddress
& rPos
, std::vector
<ScAddress
>* pGroupPos
);
2792 void EndListeningIntersectedGroups(
2793 sc::EndListeningContext
& rCxt
, const ScRange
& rRange
, std::vector
<ScAddress
>* pGroupPos
);
2795 void EndListeningGroups( const std::vector
<ScAddress
>& rPosArray
);
2796 void SetNeedsListeningGroups( const std::vector
<ScAddress
>& rPosArray
);
2798 bool BroadcastHintInternal( const ScHint
&rHint
);
2801 typedef std::unique_ptr
<ScDocument
, o3tl::default_delete
<ScDocument
>> ScDocumentUniquePtr
;
2804 * Instantiate this to ensure that subsequent modification of
2805 * the document will cause an assertion failure while this is
2808 struct ScMutationDisable
2811 ScMutationDisable(ScDocument
& rDocument
, ScMutationGuardFlags nFlags
)
2812 : mnFlagRestore(rDocument
.mnMutationGuardFlags
)
2813 , mrDocument(rDocument
)
2815 assert((mnFlagRestore
& nFlags
) == 0);
2816 mrDocument
.mnMutationGuardFlags
|= static_cast<size_t>(nFlags
);
2818 ~ScMutationDisable()
2820 mrDocument
.mnMutationGuardFlags
= mnFlagRestore
;
2822 size_t mnFlagRestore
;
2823 ScDocument
& mrDocument
;
2825 ScMutationDisable(ScDocument
& rDocument
, ScMutationGuardFlags nFlags
)
2827 (void)rDocument
; (void)nFlags
;
2833 * A pretty assertion that checks that the relevant bits in
2834 * the @nFlags are not set on the document at entry and exit.
2836 * Its primary use is for debugging threading. As such, an
2837 * @ScMutationDisable is created to forbid mutation, and this
2838 * condition is then asserted on at prominent sites that
2841 struct ScMutationGuard
2844 ScMutationGuard(ScDocument
& rDocument
, ScMutationGuardFlags nFlags
)
2845 : mnFlags(static_cast<size_t>(nFlags
))
2846 , mrDocument(rDocument
)
2848 assert((mrDocument
.mnMutationGuardFlags
& mnFlags
) == 0);
2853 assert((mrDocument
.mnMutationGuardFlags
& mnFlags
) == 0);
2856 ScDocument
& mrDocument
;
2858 ScMutationGuard(ScDocument
& rDocument
, ScMutationGuardFlags nFlags
)
2860 (void)rDocument
; (void)nFlags
;
2865 class ScDocShellRecalcGuard
2870 ScDocShellRecalcGuard(ScDocument
& rDoc
)
2873 assert(!mrDoc
.IsInDocShellRecalc());
2874 mrDoc
.SetDocShellRecalc(true);
2877 ~ScDocShellRecalcGuard()
2879 mrDoc
.SetDocShellRecalc(false);
2883 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */