Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sc/inc/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 149 kB image not shown  

Quelle  document.hxx   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */


#pragma once

#include <vcl/idle.hxx>
#include <comphelper/errcode.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <vcl/vclptr.hxx>
#include "patattr.hxx"
#include <sal/types.h>
#include "scdllapi.h"
#include "interpretercontext.hxx"
#include "rangelst.hxx"
#include "rangenam.hxx"
#include "recursionhelper.hxx"
#include "tabopparams.hxx"
#include "types.hxx"
#include <formula/grammar.hxx>
#include <formula/types.hxx>
#include "typedstrdata.hxx"
#include "calcmacros.hxx"
#include "calcconfig.hxx"
#include "sheetlimits.hxx"
#include <o3tl/deleter.hxx>
#include <o3tl/sorted_vector.hxx>
#include <svl/hint.hxx>
#include <svl/typedwhich.hxx>
#include <svl/zforlist.hxx>
#include <tools/gen.hxx>
#include <tools/solar.h>

#include <cassert>
#include <memory>
#include <map>
#include <shared_mutex>
#include <optional>
#include <set>
#include <unordered_map>
#include <vector>

#include "markdata.hxx"
#include "drwlayer.hxx"

#include <oox/helper/refvector.hxx>

namespace com::sun::star::chart2 { class XChartDocument; }
namespace oox
{
    namespace xls
    {
        class Connection;
    }
}

typedef oox::RefVector<oox::xls::Connection> ConnectionVector;

class Timer;

enum class SvtScriptType : sal_uInt8;
enum class ScMF;
enum class FormulaError : sal_uInt16;
enum class CharCompressType;
enum class EEHorizontalTextDirection;
namespace editeng { class SvxBorderLine; }
namespace formula { struct VectorRefArray; }
namespace svl {
class SharedString;
class SharedStringPool;
}

namespace tools { class Guid; }

namespace sc {

struct BroadcasterState;
struct FormulaGroupContext;
class StartListeningContext;
class EndListeningContext;
class CopyFromClipContext;
class ColumnSpanSet;
struct ColumnBlockPosition;
struct RefUpdateContext;
class EditTextIterator;
struct NoteEntry;
class DocumentLinkManager;
class CellValues;
class TableValues;
class RowHeightContext;
struct SetFormulaDirtyContext;
struct ReorderParam;
class ColumnSet;
class UpdatedRangeNames;
class ColumnIterator;
class ExternalDataMapper;
class Sparkline;
class SparklineGroup;
class SparklineList;

}

class Fraction;

class OutputDevice;
class SdrObject;
class SfxBroadcaster;
class SfxListener;
class SfxItemSet;
class SfxBindings;
class SfxPoolItem;
class SfxItemPool;
class SfxPrinter;
class SfxStyleSheetBase;
class SvMemoryStream;
class SvxBoxInfoItem;
class SvxBoxItem;
class SvxForbiddenCharactersTable;
namespace sfx2 {
    class LinkManager;
    }
class SvxSearchItem;
class XColorList;

class ScAutoFormatData;
class ScBroadcastAreaSlotMachine;
class ScChangeViewSettings;
class ScChartListenerCollection;
class ScClipOptions;
class ScColumn;
class ScConditionalFormat;
class ScConditionalFormatList;
class ScDBCollection;
class ScDBData;
class ScDetOpData;
class ScDetOpList;
class ScDocOptions;
class ScDocProtection;
class ScDocumentPool;
class ScExtDocOptions;
class ScExternalRefManager;
class ScFormulaCell;
class ScMacroManager;
class ScOutlineTable;
class ScPrintRangeSaver;
class ScStyleSheet;
class ScStyleSheetPool;
class ScTable;
class ScTableProtection;
class ScTokenArray;
class ScValidationData;
class ScValidationDataList;
class ScViewOptions;
class ScChangeTrack;
class ScEditEngineDefaulter;
class ScFieldEditEngine;
class ScNoteEditEngine;
class ScDPObject;
class ScDPCollection;
class ScMatrix;
class ScScriptTypeData;
class ScPoolHelper;
struct ScSortParam;
class ScRefreshTimerControl;
class ScUnoListenerCalls;
class ScUnoRefList;
struct RowInfo;
struct ScTableInfo;
struct ScTabOpParam;
class VirtualDevice;
class ScAutoNameCache;
class ScTemporaryChartLock;
class ScLookupCache;
class ScSortedRangeCache;
struct ScSortedRangeCacheMap;
class ScUndoManager;
class ScFormulaParserPool;
struct ScClipParam;
class ScRowBreakIterator;
struct ScSetStringParam;
struct ScColWidthParam;
class ScSheetEvents;
class ScProgress;
class SvtListener;
class ScEditDataArray;
class EditTextObject;
struct ScRefCellValue;
class ScPostIt;
struct ScSubTotalParam;
struct ScQueryParam;
class ScHint;
class SvtBroadcaster;
enum class ScDBDataPortion;
enum class ScSheetEventId;
class BitmapEx;
class ScColumnsRange;
struct ScFilterEntries;
typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes;
struct ScDataAreaExtras;
enum class ScConditionMode;

namespace sc {

typedef std::map<OUString, BitmapEx> IconSetBitmapMap;

}

namespace com::sun::star {
    namespace lang {
        struct EventObject;
    }
    namespace i18n {
        class XBreakIterator;
    }
    namespace util {
        class XModifyListener;
    }
    namespace embed {
        class XEmbeddedObject;
    }
    namespace script::vba {
        class XVBAEventProcessor;
    }
    namespace sheet {
        struct TablePageBreakData;
    }
}

namespace weld {

class Window;

}

#define SC_DOC_NEW          0xFFFF

#define SC_ASIANKERNING_INVALID         0xff

enum ScDocumentMode
{
    SCDOCMODE_DOCUMENT,
    SCDOCMODE_CLIP,
    SCDOCMODE_UNDO,
    SCDOCMODE_FUNCTIONACCESS
};

enum CommentCaptionState
{
    ALLSHOWN,                   // All comments captions are shown
    ALLHIDDEN,                  // All comments captions are hidden
    MIXED                       // There are comments in shown and hidden.
};

enum RangeNameScope
{
    GLOBAL,                    // A range name can be defined
    SHEET                      // with two scope on Manage Names dialog.
};

/// Represents the type of sheet geometry data.
enum class SheetGeomType
{
    SIZES,                     // Column widths or row heights.
    HIDDEN,                    // Hidden columns/rows.
    FILTERED,                  // Filtered columns/rows.
    GROUPS                     // Grouping of columns/rows.
};

struct ScDocStat
{
    OUString  aDocName;
    SCTAB   nTableCount;
    sal_uInt64  nCellCount;
    sal_uInt64  nFormulaCount;
    sal_uInt16  nPageCount;
    ScDocStat()
        : nTableCount(0)
        , nCellCount(0)
        , nFormulaCount(0)
        , nPageCount(0)
    {
    }
};

// DDE link modes
const sal_uInt8 SC_DDE_DEFAULT       = 0;
const sal_uInt8 SC_DDE_ENGLISH       = 1;
const sal_uInt8 SC_DDE_TEXT          = 2;
const sal_uInt8 SC_DDE_IGNOREMODE    = 255;       /// For usage in FindDdeLink() only!

// During threaded calculation fields being mutated are kept in this struct
struct ScDocumentThreadSpecific
{
    std::unique_ptr<ScRecursionHelper> xRecursionHelper; // information for recursive and iterative cell formulas
    ScInterpreterContext* pContext = nullptr;  // references the context passed around for easier access
};

/// Enumeration to determine which pieces of the code should not be mutated when set.
enum ScMutationGuardFlags
{
    // Bit mask bits
    CORE = 0x0001, /// Core calc data structures should not be mutated
};

// Stores settings used in the Goal Seek
struct ScGoalSeekSettings
{
    bool bDefined = false;
    ScAddress aFormulaCell;
    ScAddress aVariableCell;
    OUString sTargetValue;
};

typedef std::unique_ptr<ScTable, o3tl::default_delete<ScTable>> ScTableUniquePtr;

class ScDocument
{
friend class ScValueIterator;
friend class ScHorizontalValueIterator;
friend class ScDBQueryDataIterator;
friend class ScCellIterator;
template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType >
friend class ScQueryCellIteratorBase;
template< ScQueryCellIteratorAccess accessType >
friend class ScQueryCellIteratorAccessSpecific;
friend class ScHorizontalCellIterator;
friend class ScHorizontalAttrIterator;
friend class ScDocAttrIterator;
friend class ScAttrRectIterator;
friend class ScDocShell;
friend class ScDocRowHeightUpdater;
friend class ScColumnTextWidthIterator;
friend class ScTable;
friend class ScColumn;
friend struct ScRefCellValue;
friend class ScDocumentImport;
friend class sc::EditTextIterator;
friend struct ScMutationGuard;
friend struct ScMutationDisable;

    typedef std::vector<ScTableUniquePtr> TableContainer;

public:
    enum class HardRecalcState
    {
        OFF,        /// normal calculation of dependencies
        TEMPORARY,  /// CalcAll() without broadcast/notify but setting up new listeners
        ETERNAL     /// no new listeners are setup, no broadcast/notify
    };

private:
    // needs to be shared to allow the bIsClip/bIsUndo mechanism to
    // do the right thing (SCDOCMODE_CLIP, SCDOCMODE_UNDO)
    mutable std::shared_ptr<CellAttributeHelper> mpCellAttributeHelper;

public:
    SC_DLLPUBLIC CellAttributeHelper& getCellAttributeHelper() const;

    void setConnectionVector(const ConnectionVector& rIn)
    {
        maConnectionVector = rIn;
    }

    const ConnectionVector& getConnectionVector() const
    {
        return maConnectionVector;
    }

private:
    rtl::Reference<ScPoolHelper> mxPoolHelper;

    std::shared_ptr<svl::SharedStringPool> mpCellStringPool;
    std::unique_ptr<sc::DocumentLinkManager> mpDocLinkMgr;

    std::shared_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
    bool                mbFormulaGroupCxtBlockDiscard;

    ScCalcConfig        maCalcConfig;

    ScUndoManager*     mpUndoManager;
    std::unique_ptr<ScFieldEditEngine>  mpEditEngine;                   // uses pEditPool from xPoolHelper
    std::unique_ptr<ScNoteEditEngine>   mpNoteEngine;                   // uses pEditPool from xPoolHelper
    ScDocShell*     mpShell;
    VclPtr<SfxPrinter>  mpPrinter;
    VclPtr<VirtualDevice> mpVirtualDevice_100th_mm;
    std::unique_ptr<ScDrawLayer> mpDrawLayer;           // SdrModel
    rtl::Reference<XColorList> pColorList;
    std::unique_ptr<ScValidationDataList> pValidationList;              // validity
    sal_uInt32 mnLastValidationListMax = 0;
    SvNumberFormatterIndexTable* pFormatExchangeList;    // for application of number formats
    TableContainer maTabs;
    rtl::Reference<ScSheetLimits> mxSheetLimits;
    std::vector<OUString> maTabNames;               // for undo document, we need the information tab name <-> index
    mutable std::unique_ptr<ScRangeName>    pRangeName;
    std::unique_ptr<ScDBCollection>         pDBCollection;
    std::unique_ptr<ScDPCollection>         pDPCollection;
    std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock;
    std::unique_ptr<ScPatternAttr>          pSelectionAttr;                 // Attributes of a block
    ScFormulaCell*      pFormulaTree;                   // formula tree (start)
    ScFormulaCell*      pEOFormulaTree;                 // formula tree (end), last cell
    ScFormulaCell*      pFormulaTrack;                  // BroadcastTrack (start)
    ScFormulaCell*      pEOFormulaTrack;                // BroadcastTrack (end), last cell
    std::unique_ptr<ScBroadcastAreaSlotMachine> pBASM;                  // BroadcastAreas
    std::unique_ptr<ScChartListenerCollection> pChartListenerCollection;
    std::unique_ptr<SvMemoryStream>     pClipData;
    std::unique_ptr<ScDetOpList>        pDetOpList;
    std::unique_ptr<ScChangeTrack>      pChangeTrack;
    std::unique_ptr<SfxBroadcaster>     pUnoBroadcaster;
    std::unique_ptr<ScUnoListenerCalls> pUnoListenerCalls;
    std::unique_ptr<ScUnoRefList>       pUnoRefUndoList;
    std::unique_ptr<ScChangeViewSettings> pChangeViewSettings;
    std::unique_ptr<ScScriptTypeData>   pScriptTypeData;
    std::unique_ptr<ScRefreshTimerControl> pRefreshTimerControl;
    std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharacters;
    std::unique_ptr<ScDBData>               mpAnonymousDBData;
    std::unique_ptr<sc::ExternalDataMapper> mpDataMapper;

    std::unique_ptr<ScFieldEditEngine>    pCacheFieldEditEngine;

    std::unique_ptr<ScDocProtection>      pDocProtection;
    std::unique_ptr<ScClipParam>          mpClipParam;

    std::unique_ptr<ScExternalRefManager> pExternalRefMgr;
    std::unique_ptr<ScMacroManager>       mpMacroMgr;

    // mutable for lazy construction
    mutable std::unique_ptr< ScFormulaParserPool >
                        mxFormulaParserPool;            /// Pool for all external formula parsers used by this document.

    OUString       aDocName;                       // optional: name of document
    OUString       aDocCodeName;                       // optional: name of document (twice?)
    OUString       maFileURL;      // file URL for copy & paste
    ScRangePairListRef  xColNameRanges;
    ScRangePairListRef  xRowNameRanges;

    std::unique_ptr<ScViewOptions>   pViewOptions;      // view options
    std::unique_ptr<ScDocOptions>    pDocOptions;       // document options
    std::unique_ptr<ScExtDocOptions> pExtDocOptions;    // for import etc.
    std::unique_ptr<ScClipOptions> mpClipOptions;       // clipboard options
    std::unique_ptr<ScConsolidateParam> pConsolidateDlgData;
    std::unique_ptr<ScConditionMode> pConditionalFormatDialogMode;

    std::unique_ptr<ScAutoNameCache> pAutoNameCache;    // for automatic name lookup during CompileXML

    std::unique_ptr<SfxItemSet> pPreviewFont; // convert to std::unique_ptr or whatever
    ScStyleSheet*       pPreviewCellStyle;
    ScMarkData          maPreviewSelection;
    sal_Int64           nUnoObjectId;                   // counted up for UNO objects

    ErrCode             nRangeOverflowType;             // used in (xml) loading for overflow warnings

    ScRange             aEmbedRange;
    ScAddress           aCurTextWidthCalcPos;

    Idle                aTrackIdle;

    css::uno::Reference< css::script::vba::XVBAEventProcessor >
                        mxVbaEvents;

    // Stores Goal Seek settings
    ScGoalSeekSettings maGoalSeekSettings;

    ConnectionVector maConnectionVector;
public:
    /// list of ScInterpreterTableOpParams currently in use
    std::vector<ScInterpreterTableOpParams*> m_TableOpList;
    ScInterpreterTableOpParams  aLastTableOpParams;     // remember last params

private:

    LanguageType        eLanguage;                      // default language
    LanguageType        eCjkLanguage;                   // default language for asian text
    LanguageType        eCtlLanguage;                   // default language for complex text
    rtl_TextEncoding    eSrcSet;                        // during reading: source character set

    /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
        documents, GRAM_ODFF for ODF 1.2 documents. */

    formula::FormulaGrammar::Grammar  eStorageGrammar;

    sal_uInt64              nFormulaCodeInTree;             // formula RPN in the formula tree
    sal_uInt64              nXMLImportedFormulaCount;       // progress count during XML import
    sal_uInt16              nInterpretLevel;                // >0 if in interpreter
    sal_uInt16              nMacroInterpretLevel;           // >0 if macro in interpreter
    sal_uInt16              nInterpreterTableOpLevel;       // >0 if in interpreter TableOp

    ScDocumentThreadSpecific maNonThreaded;

    // There can be only one ScDocument being calculated in a thread at a time, so we can use a
    // plain thread_local static member.
    thread_local static ScDocumentThreadSpecific maThreadSpecific;

    mutable ScInterpreterContext maInterpreterContext;

    std::shared_mutex mScLookupMutex; // protection for thread-unsafe parts of handling ScLookup
    std::unique_ptr<ScSortedRangeCacheMap> mxScSortedRangeCache; // cache for unsorted lookups

    static const sal_uInt16 nSrcVer;                        // file version (load/save)
    sal_uInt16              nFormulaTrackCount;
    HardRecalcState         eHardRecalcState;               // off, temporary, eternal
    SCTAB                   nVisibleTab;                    // for OLE etc., don't use inside ScDocument
    SCCOL                   nPosLeft;                       // for OLE etc., don't use inside ScDocument
    SCROW                   nPosTop;                        // for OLE etc., don't use inside ScDocument

    ScLkUpdMode         eLinkMode;

    bool                bAutoCalc;                      // calculate automatically
    bool                bAutoCalcShellDisabled;         // in/from/for ScDocShell disabled
    // are there ForcedFormulas which have to be calculated
    // in interaction with ScDocShell SetDocumentModified,
    // AutoCalcShellDisabled and TrackFormulas
    bool                bForcedFormulaPending;
    bool                bCalculatingFormulaTree;
    bool                bIsClip;
    bool                bIsUndo;
    bool                bIsFunctionAccess;
    bool                bIsVisible;                     // set from view ctor

    bool                bIsEmbedded;                    // display/adjust Embedded area?

    // no broadcast, construct no listener during insert from a different
    // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad
    bool                bInsertingFromOtherDoc;
    bool                bLoadingMedium;
    bool                bImportingXML;      // special handling of formula text
    bool                mbImportingXLSX;
    bool                bCalcingAfterLoad;              // in CalcAfterLoad TRUE
    // don't construct/destruct listeners temporarily
    bool                bNoListening;
    bool                mbIdleEnabled;
    bool                bInLinkUpdate;                  // TableLink or AreaLink
    bool                bChartListenerCollectionNeedsUpdate;
    // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever)
    bool                bHasForcedFormulas;
    // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore)
    bool                bInDtorClear;
    // expand reference if insert column/row takes place at the border
    // of a reference
    // is fetched in each UpdateReference from InputOptions,
    // assigned, and restored at the end of UpdateReference
    bool                bExpandRefs;
    // for detective update, is set for each change of a formula
    bool                bDetectiveDirty;
    // If the pointer is set, formula cells will not be automatically grouped into shared formula groups,
    // instead the range will be extended to contain all such cells.
    std::unique_ptr< ScRange > pDelayedFormulaGrouping;
    // If non-empty, ScColumn::StartListeningFormulaCells() calls may be delayed using this,
    // avoiding repeated calling for the same cells in the given range. The function will be called once
    // later for all the cells in the range.
    std::unordered_map< ScColumn*, std::pair<SCROW, SCROW>> pDelayedStartListeningFormulaCells;
    // Cells will not delete their broadcasters if delayed, avoiding possible extensive mdds vector changes.
    bool                bDelayedDeletingBroadcasters;

    bool                bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice

    CharCompressType    nAsianCompression;
    sal_uInt8           nAsianKerning;

    bool                bPastingDrawFromOtherDoc;

    sal_uInt8           nInDdeLinkUpdate;   // originating DDE links (stacked bool)

    bool                bInUnoBroadcast;
    bool                bInUnoListenerCall;
    sal_uInt32          nAdjustHeightLock;
    formula::FormulaGrammar::Grammar  eGrammar;

    mutable bool        bStyleSheetUsageInvalid;

    bool                mbUndoEnabled:1;
    bool                mbExecuteLinkEnabled:1;
    bool                mbChangeReadOnlyEnabled:1;    // allow changes in read-only document (for API import filters)
    bool                mbStreamValidLocked:1;
    bool                mbUserInteractionEnabled:1;  // whether or not to launch any kind of interactive dialogs.

    sal_Int16           mnNamedRangesLockCount;

    std::set<ScFormulaCell*> maSubTotalCells;


    bool mbEmbedFonts : 1;
    bool mbEmbedUsedFontsOnly : 1;
    bool mbEmbedFontScriptLatin : 1;
    bool mbEmbedFontScriptAsian : 1;
    bool mbEmbedFontScriptComplex : 1;

    sal_Int32 mnImagePreferredDPI;

    std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;

    bool                mbTrackFormulasPending  : 1;
    bool                mbFinalTrackFormulas    : 1;
    // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress.
    bool                mbDocShellRecalc        : 1;
    // This indicates if a ScOutputData::LayoutStrings() is in progress.
    bool                mbLayoutStrings         : 1;

    size_t              mnMutationGuardFlags;

    bool mbConnectionXml = false;
    bool mbCustomXml = false;
    OUString aCustomXmlFragmentPath;

public:
    bool                     IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder);
    void                     GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge);

    void setHasConnectionXml(bool bUse) { mbConnectionXml = bUse; }
    bool hasConnectionXml() { return mbConnectionXml; }

    void setHasCustomXml(bool bUse, const OUString& sCustomXmlPath)
    {
        mbCustomXml = bUse;
        aCustomXmlFragmentPath = sCustomXmlPath;
    }
    const OUString & getCustomXmlItems() { return aCustomXmlFragmentPath; }
    bool hasCustomXml() { return mbCustomXml; }

    bool IsEmbedFonts() const { return mbEmbedFonts; }
    bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly; }
    bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin; }
    bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian; }
    bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex; }

    void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; }
    void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; }
    void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; }
    void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
    void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }

    void SetImagePreferredDPI(sal_Int32 nValue) { mnImagePreferredDPI = nValue; }
    sal_Int32 GetImagePreferredDPI() { return mnImagePreferredDPI; }

    SC_DLLPUBLIC sal_uInt64  GetCellCount() const;       // all cells
    SC_DLLPUBLIC sal_uInt64  GetFormulaGroupCount() const;       // all cells
    sal_uInt64               GetCodeCount() const;       // RPN-Code in formulas
    DECL_LINK( GetUserDefinedColor, sal_uInt16, Color* );
                                                                // number formatter
public:
    SC_DLLPUBLIC                ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
                                            ScDocShell* pDocShell = nullptr );
    SC_DLLPUBLIC                ~ScDocument();

    void              SetName( const OUString& r ) { aDocName = r; }
    const OUString&   GetCodeName() const { return aDocCodeName; }
    void              SetCodeName( const OUString& r ) { aDocCodeName = r; }
    const OUString&   GetFileURL() const { return maFileURL; }

    void              GetDocStat( ScDocStat& rDocStat );

    SC_DLLPUBLIC void  InitDrawLayer( ScDocShell* pDocShell = nullptr );

    ScInterpreterContext& GetNonThreadedContext() const
    {
        assert(!IsThreadedGroupCalcInProgress());
        return maInterpreterContext;
    }
    // Uses thread_local.
    ScInterpreterContext& GetThreadedContext() const
    {
        return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext();
    }
    void SetupContextFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
    void MergeContextBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
    void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; }
    bool IsThreadedGroupCalcInProgress() const { (void)thisreturn ScGlobal::bThreadedGroupCalcInProgress; }

    SC_DLLPUBLIC sfx2::LinkManager*       GetLinkManager();
    SC_DLLPUBLIC const sfx2::LinkManager* GetLinkManager() const;

    sc::DocumentLinkManager&       GetDocLinkManager();
    const sc::DocumentLinkManager& GetDocLinkManager() const;

    SC_DLLPUBLIC const ScDocOptions&    GetDocOptions() const;
    SC_DLLPUBLIC void                   SetDocOptions( const ScDocOptions& rOpt );
    SC_DLLPUBLIC const ScViewOptions&   GetViewOptions() const;
    SC_DLLPUBLIC void                   SetViewOptions( const ScViewOptions& rOpt );
    void                                SetPrintOptions();

    ScExtDocOptions*            GetExtDocOptions()  { return pExtDocOptions.get(); }
    SC_DLLPUBLIC void           SetExtDocOptions( std::unique_ptr<ScExtDocOptions> pNewOptions );

    ScClipOptions*              GetClipOptions()    { return mpClipOptions.get(); }
    void                        SetClipOptions(std::unique_ptr<ScClipOptions> pClipOptions);

    SC_DLLPUBLIC void           GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
    void                        SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );

    void                        SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData );
    const ScConsolidateParam*   GetConsolidateDlgData() const { return pConsolidateDlgData.get(); }
    void SetEasyConditionalFormatDialogData(std::unique_ptr<ScConditionMode> pMode);
    const ScConditionMode* GetEasyConditionalFormatDialogData() const
    {
        return pConditionalFormatDialogMode.get();
    }

    void                        Clear( bool bFromDestructor = false );

    std::unique_ptr<ScFieldEditEngine> CreateFieldEditEngine();
    void                        DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine);

    /**
     * Get all range names that are local to each table.  It only returns
     * non-empty range name set.
     */

    SC_DLLPUBLIC void          GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
    SC_DLLPUBLIC void          SetAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap);
    SC_DLLPUBLIC void          GetRangeNameMap(std::map<OUString, ScRangeName*>& rRangeName);
    SC_DLLPUBLIC ScRangeName*  GetRangeName(SCTAB nTab) const;
    SC_DLLPUBLIC ScRangeName*  GetRangeName() const;
    void                       SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew);
    void                       SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName );
    bool                       IsAddressInRangeName( RangeNameScope eScope, const ScAddress& rAddress);

    /** Find a named expression / range name in either global or a local scope.
        @param  nTab
                If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab.
        @param  nIndex
                Index of named expression / range name.
        @return nullptr if indexed name not found.
     */

    ScRangeData* FindRangeNameBySheetAndIndex( SCTAB nTab, sal_uInt16 nIndex ) const;

    /** Recursively find all named expressions that directly or indirectly
        (nested) reference a given sheet, starting from a given named
        expression nTokenTab/nTokenIndex.

        Used to collect all named expressions/ranges that will need to be
        copied along when copying sheets.

        The different tab/sheets passed cater for the situation that a sheet is
        copied and was already inserted and global names are already adjusted
        but the sheet-local names of the shifted original sheet are not yet. If
        no sheet was inserted and global and local names' references not
        updated yet, then all 4 tab arguments would be identical.

        @param  nTokenTab
                Tab/sheet on which to find the name, -1 if global scope.
                For example obtained from ocName token.

        @param  nTokenIndex
                Index of named expression. For example obtained from ocName token.

        @param  nGlobalRefTab
                Tab to check if used in global names.

        @param  nLocalRefTab
                Tab to check if used in sheet-local names.

        @param  nOldTokenTab
                The original tab of the copied sheet, used as sheet-local
                base position for relative references.

        @param  nOldTokenTabReplacement
                The replacement to use for relative references if the name
                encountered uses nOldTokenTab as base position.

        @param  bSameDoc
                FALSE if collecting names for a sheet to be copied to another
                document. Then all names encountered are considered to be
                referencing the sheet. Else TRUE if collecting names to be
                copied into the same document.

        @param  nRecursion
                Recursion guard, initialize with 0.
      */

    bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames& rIndexes,
            SCTAB nTokenTab, const sal_uInt16 nTokenIndex,
            SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement,
            bool bSameDoc, int nRecursion ) const;

    /** If necessary (name references sheet rOldPos.Tab()) copy and adjust
        named expression/range from sheet-local to sheet-local, or global to
        sheet-local if bGlobalNamesToLocal==true.

        Also copies nested names and adjusts the ocName tokens of the calling name.

        @param  rSheet
                On entry, the original sheet of the named expression/range, <0 global.
                On return TRUE, the new sheet. Else unchanged.

        @param  rIndex
                On entry, the original index of the named expression/range.
                On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged.

        @param  rpRangeData
                On entry, the pointer to the original named expression/range.
                On return TRUE, the pointer to the new copied name, or nullptr if hits happened.

        @param  rNewPos
                New position of formula cell if called for that, else new base
                position of a to be created new name adjusted for Tab.
                rNewPos.nTab MUST point to the new sheet copied to.

        @param  rOldPos
                Old position of formula cell if called for that, else base
                position of the existing name adjusted for Tab.
                rOldPos.nTab MUST point to the old sheet copied from.

        @param  bGlobalNamesToLocal
                If TRUE, affected global names are copied to sheet-local names.
                If FALSE, global names are copied to global names in another document.

        @param  bUsedByFormula
                If TRUE, forces a global name to be affected/used.
                If FALSE, a global name is only affected if it evaluates to be
                referencing the sheet.

        @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex.
                FALSE if nothing to be done.
     */

    bool CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData, ScDocument& rNewDoc,
            const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal,
            const bool bUsedByFormula ) const;

    /**
     * Call this immediately before updating all named ranges.
     */

    SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, ScRangeName>&&nbsp;rRangeMap );
    SC_DLLPUBLIC void PreprocessRangeNameUpdate();
    SC_DLLPUBLIC void PreprocessDBDataUpdate();
    /**
     * Call this immediately after updating named ranges.
     */

    SC_DLLPUBLIC void CompileHybridFormula();

    /**
     * Insert a new named expression to the global scope.
     *
     * @param rName name for the expression.
     * @param rPos base position.
     * @param rExpr formula expression to be associated with the name.  The
     *              current grammar is used to compile this expression.
     *
     * @return true if inserted successfully, false otherwise.
     */

    bool InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr );

    /**
     * Insert a new named expression to a sheet-local scope.
     *
     * @param nTab  sheet for local scope.
     * @param rName name for the expression.
     * @param rPos base position.
     * @param rExpr formula expression to be associated with the name.  The
     *              current grammar is used to compile this expression.
     *
     * @return true if inserted successfully, false otherwise.
     */

    bool InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPosconst OUString& rExpr );

    /** Obtain the sheet separator corresponding to the document's grammar.

        @return '.' for our own grammars, '!' for Excel grammars.
     */

    SC_DLLPUBLIC sal_Unicode GetSheetSeparator() const;

    SCTAB GetMaxTableNumber() const { return static_cast<SCTAB>(maTabs.size()) - 1; }

    ScRangePairList*    GetColNameRanges() { return xColNameRanges.get(); }
    ScRangePairList*    GetRowNameRanges() { return xRowNameRanges.get(); }
    ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
    ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }

    SC_DLLPUBLIC SCCOL ClampToAllocatedColumns(SCTAB nTab, SCCOL nCol) const;
    SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const;

    SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();}
    void                         SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection,
                                                  bool bRemoveAutoFilter = false );
    const ScDBData*              GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const;
    ScDBData*                    GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion);
    SC_DLLPUBLIC const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
    SC_DLLPUBLIC ScDBData*       GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
    void                         RefreshDirtyTableColumnNames();
    SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();

    SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, OUString&&nbsp;rName,
                                                     bool* pSheetLocal = nullptr ) const;

    SC_DLLPUBLIC bool                  HasPivotTable() const;
    SC_DLLPUBLIC ScDPCollection*       GetDPCollection();
    SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const;
    SC_DLLPUBLIC ScDPObject*           GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
    SC_DLLPUBLIC ScDPObject*           GetDPAtCursor(ScAddress const& rAddress) const
    {
        return GetDPAtCursor(rAddress.Col(), rAddress.Row(), rAddress.Tab());
    }
    SC_DLLPUBLIC bool HasDataPilotAtPosition(ScAddress const& rAddress) const
    {
        return GetDPAtCursor(rAddress) != nullptr;
    }
    ScDPObject*                        GetDPAtBlock( const ScRange& rBlock ) const;

    void                               StopTemporaryChartLock();

    void                               EnsureGraphicNames();

    SdrObject*      GetObjectAtPoint( SCTAB nTab, const Point& rPos );
    bool            HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName );

    css::uno::Reference< css::chart2::XChartDocument > GetChartByName( std::u16string_view rChartName );

    SC_DLLPUBLIC void GetChartRanges( std::u16string_view rChartName, std::vector< ScRangeList >& rRanges, const ScDocument& rSheetNameDoc );
    void              SetChartRanges( std::u16string_view rChartName, const std::vector< ScRangeList >& ;rRanges );

    void              UpdateChartArea( const OUString& rChartName, const ScRange& rNewArea,
                                       bool bColHeaders, bool bRowHeaders, bool bAdd );
    void              UpdateChartArea( const OUString& rChartName,
                                       const ScRangeListRef& rNewList,
                                       bool bColHeaders, bool bRowHeaders, bool bAdd );
    void              GetOldChartParameters( std::u16string_view rName,
                                             ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders );
    css::uno::Reference<
            css::embed::XEmbeddedObject >
                    FindOleObjectByName( std::u16string_view rName );

    SC_DLLPUBLIC void MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true );

    SCTAB             GetVisibleTab() const       { return nVisibleTab; }
    SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)   { nVisibleTab = nTab; }
    SCCOL             GetPosLeft() const          { return nPosLeft; }
    SC_DLLPUBLIC void SetPosLeft(SCCOL nCol)      { nPosLeft = nCol; }
    SCROW             GetPosTop() const           { return nPosTop; }
    SC_DLLPUBLIC void SetPosTop(SCROW nRow)       { nPosTop = nRow; }

    SC_DLLPUBLIC bool HasTable( SCTAB nTab ) const;
    SC_DLLPUBLIC bool GetHashCode( SCTAB nTab, sal_Int64& rHashCode) const;
    SC_DLLPUBLIC bool GetName( SCTAB nTab, OUString& rName ) const;
    SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const;
    SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
    SC_DLLPUBLIC bool GetTotalsRowBelow( SCTAB nTab ) const;
    SC_DLLPUBLIC bool SetTotalsRowBelow( SCTAB nTab, bool bVal );
    SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
    SC_DLLPUBLIC SCCOL MaxCol() const { return mxSheetLimits->mnMaxCol; }
    SC_DLLPUBLIC SCROW MaxRow() const { return mxSheetLimits->mnMaxRow; }
    SC_DLLPUBLIC SCCOL GetMaxColCount() const { return mxSheetLimits->GetMaxColCount(); }
    SC_DLLPUBLIC SCROW GetMaxRowCount() const { return mxSheetLimits->GetMaxRowCount(); }
    SC_DLLPUBLIC const OUString & MaxRowAsString() const { return mxSheetLimits->MaxRowAsString(); }
    SC_DLLPUBLIC const OUString & MaxColAsString() const { return mxSheetLimits->MaxColAsString(); }
    ScSheetLimits& GetSheetLimits() const { return *mxSheetLimits; }
    [[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mxSheetLimits->mnMaxCol); }
    [[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mxSheetLimits->mnMaxRow); }
    [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { return ::ValidColRow(nCol, nRow, MaxCol(), MaxRow()); }
    [[nodiscard]] bool ValidColRowTab(SCCOL nCol, SCROW nRow, SCTAB nTab) const { return ::ValidColRowTab(nCol, nRow, nTab, MaxCol(), MaxRow()); }
    [[nodiscard]] bool ValidRange(const ScRange& rRange) const { return ::ValidRange(rRange, MaxCol(), MaxRow()); }
    [[nodiscard]] bool ValidAddress(const ScAddress& rAddress) const { return ::ValidAddress(rAddress, MaxCol(), MaxRow()); }
    [[nodiscard]] SCCOL SanitizeCol( SCCOL nCol ) const { return ::SanitizeCol(nCol, MaxCol()); }
    [[nodiscard]] SCROW SanitizeRow( SCROW nRow ) const { return ::SanitizeRow(nRow, MaxRow()); }

    SC_DLLPUBLIC std::vector<OUString> GetAllTableNames() const;

    const OUString & GetCopyTabName(SCTAB nTab) const;

    SC_DLLPUBLIC void      SetAnonymousDBData(SCTAB nTab, std::unique_ptr<ScDBData> pDBData);
    SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab);

    /** One document global anonymous database range for temporary operations,
        used if the corresponding sheet-local anonymous database range is
        already used with AutoFilter and range differs. Not stored in document
        files. */

    SC_DLLPUBLIC void             SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
    SC_DLLPUBLIC ScDBData*        GetAnonymousDBData();

    SC_DLLPUBLIC SCTAB            GetTableCount() const;
    SvNumberFormatterIndexTable*  GetFormatExchangeList() const { return pFormatExchangeList; }

    SC_DLLPUBLIC ScDocProtection*      GetDocProtection() const;
    SC_DLLPUBLIC void                  SetDocProtection(const ScDocProtection* pProtect);
    SC_DLLPUBLIC bool                  IsDocProtected() const;
    bool                               IsDocEditable() const;
    SC_DLLPUBLIC bool                  IsTabProtected( SCTAB nTab ) const;
    SC_DLLPUBLIC const ScTableProtection* GetTabProtection(SCTAB nTab) const;
    SC_DLLPUBLIC void                  SetTabProtection(SCTAB nTab, const ScTableProtection* pProtect);
    void                               CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest);

    void            LockTable(SCTAB nTab);
    void            UnlockTable(SCTAB nTab);

    bool            IsBlockEditable( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
                                     SCCOL nEndCol, SCROW nEndRow,
                                     bool* pOnlyNotBecauseOfMatrix = nullptr,
                                     bool bNoMatrixAtAll = false ) const;
    bool            IsSelectionEditable( const ScMarkData& rMark,
                                         bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
    bool            HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow,
                                                    SCCOL nEndCol, SCROW nEndRow,
                                                    const ScMarkData& rMark ) const;

    bool            IsEditActionAllowed( sc::EditAction eAction, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
                                         SCCOL nEndCol, SCROW nEndRow ) const;
    bool            IsEditActionAllowed( sc::EditAction eAction, const ScMarkData& rMark, SCCOL nStartCol,
                                         SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;

    SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );

    bool            IsEmbedded() const { return bIsEmbedded;}
    void            GetEmbedded( ScRange& rRange ) const;
    void            SetEmbedded( const ScRange& rRange );
    void            ResetEmbedded();
    tools::Rectangle       GetEmbeddedRect() const;                        // 1/100 mm
    void            SetEmbedded( SCTAB nTab, const tools::Rectangle& rRect );          // from VisArea (1/100 mm)

    static SC_DLLPUBLIC bool ValidTabName( const OUString& rName );

    SC_DLLPUBLIC bool           ValidNewTabName( const OUString& rName ) const;
    SC_DLLPUBLIC void           CreateValidTabName(OUString& rName) const;
    SC_DLLPUBLIC void           CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount) const;

    void AppendTabOnLoad(const OUString& rName);
    void SetTabNameOnLoad(SCTAB nTab, const OUString& rName);
    void InvalidateStreamOnSave();

    SC_DLLPUBLIC bool           InsertTab( SCTAB nPos, const OUString& rName,
                                          bool bExternalDocument = falsebool bUndoDeleteTab = false );

    SC_DLLPUBLIC bool           InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
                                            bool bNamesValid = false );
    SC_DLLPUBLIC bool           DeleteTabs( SCTAB nTab, SCTAB nSheets );
    SC_DLLPUBLIC bool           DeleteTab( SCTAB nTab );
    SC_DLLPUBLIC bool           RenameTab( SCTAB nTab, const OUString& rName,
                                           bool bExternalDocument = false );
    bool                        MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr );
    SC_DLLPUBLIC bool           CopyTab( SCTAB nOldPos, SCTAB nNewPos,
                                         const ScMarkData* pOnlyMarked = nullptr );
    SC_DLLPUBLIC bool      TransferTab(ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
                                            bool bInsertNew = true,
                                            bool bResultsOnly = false );
    SC_DLLPUBLIC void           TransferDrawPage(const ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
    SC_DLLPUBLIC void           SetVisible( SCTAB nTab, bool bVisible );
    SC_DLLPUBLIC bool           IsVisible( SCTAB nTab ) const;
    bool                        IsStreamValid( SCTAB nTab ) const;
    void                        SetStreamValid( SCTAB nTab, bool bSet, bool bIgnoreLock = false );
    void                        LockStreamValid( bool bLock );
    bool                        IsStreamValidLocked() const { return mbStreamValidLocked; }
    bool                        IsPendingRowHeights( SCTAB nTab ) const;
    void                        SetPendingRowHeights( SCTAB nTab, bool bSet );
    sal_uInt16 GetSheetOptimalMinRowHeight(SCTAB nTab) const;
    SC_DLLPUBLIC void           SetLayoutRTL( SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
    SC_DLLPUBLIC bool           IsLayoutRTL( SCTAB nTab ) const;
    SC_DLLPUBLIC bool           IsNegativePage( SCTAB nTab ) const;
    SC_DLLPUBLIC void           SetScenario( SCTAB nTab, bool bFlag );
    SC_DLLPUBLIC bool           IsScenario( SCTAB nTab ) const;
    SC_DLLPUBLIC void           GetScenarioData(SCTAB nTab, OUString& rComment,
                                                Color& rColor, ScScenarioFlags &rFlags) const;
    SC_DLLPUBLIC void           SetScenarioData(SCTAB nTab, const OUString& rComment,
                                                const Color& rColor, ScScenarioFlags nFlags);
    SC_DLLPUBLIC Color          GetTabBgColor( SCTAB nTab ) const;
    SC_DLLPUBLIC void           SetTabBgColor( SCTAB nTab, const Color& rColor );
    SC_DLLPUBLIC bool           IsDefaultTabBgColor( SCTAB nTab ) const;
    void                        GetScenarioFlags(SCTAB nTab, ScScenarioFlags &rFlags) const;
    SC_DLLPUBLIC bool           IsActiveScenario( SCTAB nTab ) const;
    SC_DLLPUBLIC void           SetActiveScenario( SCTAB nTab, bool bActive );      // only for Undo etc.
    SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const;
    SC_DLLPUBLIC formula::FormulaGrammar::Grammar           GetGrammar() const { return eGrammar;}
    SC_DLLPUBLIC void                                       SetGrammar( formula::FormulaGrammar::Grammar eGram );
    SC_DLLPUBLIC ScLinkMode                                 GetLinkMode( SCTAB nTab ) const;
    bool                                                    IsLinked( SCTAB nTab ) const;
    SC_DLLPUBLIC OUString                                   GetLinkDoc( SCTAB nTab ) const;
    OUString                                                GetLinkFlt( SCTAB nTab ) const;
    OUString                                                GetLinkOpt( SCTAB nTab ) const;
    SC_DLLPUBLIC OUString                                   GetLinkTab( SCTAB nTab ) const;
    sal_Int32                                               GetLinkRefreshDelay( SCTAB nTab ) const;
    void                                                    SetLink( SCTAB nTab, ScLinkMode nMode, const OUString& rDoc,
                                                                     const OUString& rFilter, const OUString& rOptions,
                                                                     const OUString& rTabName, sal_Int32 nRefreshDelay );
    bool                                                    HasLink( std::u16string_view rDoc,
                                                                     std::u16string_view rFilter, std::u16string_view rOptions ) const;
    SC_DLLPUBLIC bool                                       LinkExternalTab( SCTAB& nTab, const OUString& aDocTab,
                                                                             const OUString& aFileName,
                                                                             const OUString& aTabName );

    bool                               HasExternalRefManager() const { return bool(pExternalRefMgr); }
    SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
    bool                               IsInExternalReferenceMarking() const;
    void                               MarkUsedExternalReferences();
    bool                               MarkUsedExternalReferences( const ScTokenArray& rArr, const ScAddress& rPos );

    /** Returns the pool containing external formula parsers. Creates the pool
        on first call. */

    ScFormulaParserPool& GetFormulaParserPool() const;

    bool            HasAreaLinks() const;
    void            UpdateExternalRefLinks(weld::Window* pWin);
    void            UpdateAreaLinks();

                    // originating DDE links
    void            IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; }
    void            DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; }
    bool            IsInDdeLinkUpdate() const   { return nInDdeLinkUpdate != 0; }

    SC_DLLPUBLIC void CopyDdeLinks( ScDocument& rDestDoc ) const;

    /** Tries to find a DDE link with the specified connection data.
        @param rnDdePos  (out-param) Returns the index of the DDE link (does not include other links from link manager).
        @return  true = DDE link found, rnDdePos valid. */

    SC_DLLPUBLIC bool FindDdeLink( std::u16string_view rAppl, std::u16string_view rTopic,
                                   std::u16string_view rItem, sal_uInt8 nMode, size_t& rnDdePos );

    /** Returns the connection data of the specified DDE link.
        @param nDdePos  Index of the DDE link (does not include other links from link manager).
        @param rAppl  (out-param) The application name.
        @param rTopic  (out-param) The DDE topic.
        @param rItem  (out-param) The DDE item.
        @return  true = DDE link found, out-parameters valid. */

    bool            GetDdeLinkData( size_t nDdePos, OUString& rAppl, OUString& rTopic, OUString&&nbsp;rItem ) const;
    /** Returns the link mode of the specified DDE link.
        @param nDdePos  Index of the DDE link (does not include other links from link manager).
        @param rnMode  (out-param) The link mode of the specified DDE link.
        @return  true = DDE link found, rnMode valid. */

    bool            GetDdeLinkMode( size_t nDdePos, sal_uInt8& rnMode ) const;
    /** Returns the result matrix of the specified DDE link.
        @param nDdePos  Index of the DDE link (does not include other links from link manager).
        @return  The result matrix, if the DDE link has been found, 0 otherwise. */

    SC_DLLPUBLIC const ScMatrix* GetDdeLinkResultMatrix( size_t nDdePos ) const;

    /** Tries to find a DDE link or creates a new, if not extant.
        @param pResults  If not 0, sets the matrix as DDE link result matrix (also for existing links).
        @return  true = DDE link found; false = Unpredictable error occurred, no DDE link created. */

    SC_DLLPUBLIC bool            CreateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem, sal_uInt8 nMode, const ScMatrixRef& pResults );
    /** Sets a result matrix for the specified DDE link.
        @param nDdePos  Index of the DDE link (does not include other links from link manager).
        @param pResults  The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
        @return  true = DDE link found and matrix set. */

    bool            SetDdeLinkResultMatrix( size_t nDdePos, const ScMatrixRef& pResults );

    SAL_RET_MAYBENULL SfxBindings*  GetViewBindings();
    ScDocShell*                     GetDocumentShell() const    { return mpShell; }
    SC_DLLPUBLIC ScDrawLayer*       GetDrawLayer() { return mpDrawLayer.get();  }
    SC_DLLPUBLIC const ScDrawLayer* GetDrawLayer() const { return mpDrawLayer.get();  }
    SfxBroadcaster*                 GetDrawBroadcaster();       // to avoid header
    void                            BeginDrawUndo();

    void            BeginUnoRefUndo();
    bool            HasUnoRefUndo() const       { return ( pUnoRefUndoList != nullptr ); }
    [[nodiscard]]
    std::unique_ptr<ScUnoRefList> EndUnoRefUndo();            // must be deleted by caller!
    sal_Int64       GetNewUnoId() { return ++nUnoObjectId; }
    void            AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges );

    static bool IsChart( const SdrObject* pObject );

    void              UpdateChartRef( UpdateRefMode eUpdateRefMode,
                                    SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
                                    SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
                                    SCCOL nDx, SCROW nDy, SCTAB nDz );
                    //! only assigns the new RangeList, no ChartListener or the like
    void            SetChartRangeList( std::u16string_view rChartName,
                                       const ScRangeListRef& rNewRangeListRef );

    void            StartAnimations( SCTAB nTab );

    bool            HasBackgroundDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
    bool            HasAnyDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;

    const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const;
    void                 SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew );
    bool                 HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents = false ) const;
    bool                 HasAnySheetEventScript( ScSheetEventId nEvent, bool bWithVbaEvents = false ) const;  // on any sheet

    bool            HasAnyCalcNotification() const;
    bool            HasCalcNotification( SCTAB nTab ) const;
    void            SetCalcNotification( SCTAB nTab );
    void            ResetCalcNotifications();

    SC_DLLPUBLIC ScOutlineTable*    GetOutlineTable( SCTAB nTab, bool bCreate = false );
    bool                            SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline );

    void                            DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
                                                   SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );

    bool            DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
    void            RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
    bool            TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam );
    bool            HasSubTotalCells( const ScRange& rRange );

    SC_DLLPUBLIC void EnsureTable( SCTAB nTab );

                    //  return TRUE = number format is set
    SC_DLLPUBLIC bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
                                 const ScSetStringParam * pParam = nullptr );
    SC_DLLPUBLIC bool SetString( const ScAddress& rPos, const OUString& rString,
                                 const ScSetStringParam* pParam = nullptr );

    /**
     * This method manages the lifecycle of the passed edit text object. When
     * the text is successfully inserted, the cell takes over the ownership of
     * the text object. If not, the text object gets deleted.
     *
     * <p>The caller must ensure that the passed edit text object <i>uses the
     * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
     * This is very important.</p>
     */

    SC_DLLPUBLIC bool  SetEditText( const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText );
    void               SetEditText( const ScAddress& rPos, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
    SC_DLLPUBLIC void  SetEditText( const ScAddress& rPos, const OUString& rStr );
    SC_DLLPUBLIC SCROW GetFirstEditTextRow( const ScRange& rRange ) const;

    /**
     * Call this if you are not sure whether to put this as an edit text or a
     * simple text.
     */

    SC_DLLPUBLIC void SetTextCell(const ScAddress& rPos, const OUString& rStr,
                                  const ScSetStringParam* pParam = nullptr);

    void              SetEmptyCell( const ScAddress& rPos );
    SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
    SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal );
    void              SetValues( const ScAddress& rPos, const std::vector<double>& rVals );
    void              SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError);
    SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const ScTokenArray& rArray );
    SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const OUString& rFormula,
                                  formula::FormulaGrammar::Grammar eGram );

    /**
     * Set formula cell, and transfer its ownership to the document. This call
     * attempts to group the passed formula cell with the adjacent cells or
     * cell groups if appropriate.
     *
     * @return pCell if it was successfully inserted, NULL otherwise. pCell
     *         is deleted automatically on failure to insert.
     */

    SC_DLLPUBLIC ScFormulaCell*  SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell );
    bool                         SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells );

    /**
     * Check if there is at least one formula cell in specified range.
     */

    bool              HasFormulaCell( const ScRange& rRange ) const;
    SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
                                        SCCOL nCol2, SCROW nRow2,
                                        const ScMarkData& rMark,
                                        const OUString& rFormula,
                                        const ScTokenArray* p = nullptr,
                                        const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
    SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam,   // multi-operation
                                    SCCOL nCol1, SCROW nRow1,
                                    SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);

    SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab,
                                     ScInterpreterContext* pContext = nullptr ) const;
    SC_DLLPUBLIC OUString GetString( const ScAddress& rPos,
                                     ScInterpreterContext* pContext = nullptr ) const;

    /**
     * Return a pointer to the double value stored in value cell.
     *
     * @param rPos cell position
     *
     * @return pointer to the double value stored in a numeric cell, or NULL
     *         if the cell at specified position is not a numeric cell.
     */

    SC_DLLPUBLIC double*                      GetValueCell( const ScAddress& rPos );

    SC_DLLPUBLIC svl::SharedStringPool&       GetSharedStringPool();
    const svl::SharedStringPool&              GetSharedStringPool() const;

    svl::SharedString                         GetSharedString( const ScAddress& rPos ) const;

    std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext();
    void                                      DiscardFormulaGroupContext();
    void                                      BlockFormulaGroupContextDiscard( bool block )
                                                  { mbFormulaGroupCxtBlockDiscard = block; }

    // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
    SC_DLLPUBLIC OUString                     GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, bool bForceSystemLocale = false ) const;
    FormulaError                              GetStringForFormula( const ScAddress& rPos, OUString& rString );
    SC_DLLPUBLIC double                       GetValue( const ScAddress& rPos ) const;
    SC_DLLPUBLIC double                       GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
    SC_DLLPUBLIC const EditTextObject*        GetEditText( const ScAddress& rPos ) const;
    void                                      RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr );
    SC_DLLPUBLIC double                       RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScInterpreterContext* pContext = nullptr ) const;
    SC_DLLPUBLIC sal_uInt32                   GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
    sal_uInt32                                GetNumberFormat( const ScRange& rRange ) const;
    SC_DLLPUBLIC sal_uInt32                   GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& ) const;
    SC_DLLPUBLIC void                         SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat );

    void                                      GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNumFormatType&&nbsp;nType, sal_uInt32& nIndex, const ScAddress& rPos ) const;
    SC_DLLPUBLIC const ScFormulaCell*         GetFormulaCell( const ScAddress& rPos ) const;
    SC_DLLPUBLIC ScFormulaCell*               GetFormulaCell( const ScAddress& rPos );
    SC_DLLPUBLIC OUString                     GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
    SC_DLLPUBLIC CellType                     GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
    SC_DLLPUBLIC CellType                     GetCellType( const ScAddress& rPos ) const;

    SC_DLLPUBLIC bool                         HasData( SCCOL nCol, SCROW nRow, SCTAB nTab );
    SC_DLLPUBLIC bool                         HasStringData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
    SC_DLLPUBLIC bool                         HasValueData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
    SC_DLLPUBLIC bool                         HasValueData( const ScAddress& rPos ) const;
    bool                                      HasStringCells( const ScRange& rRange ) const;

    /** Returns true, if there is any data to create a selection list for rPos. */
    bool            HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
    bool            HasValidationData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;

    /**
     * Check if the specified range contains either: 1) one non-empty cell, 2)
     * more than one non-empty cells, or 3) totally empty.  In case the range
     * contains at least one non-empty cell, specify the position of the first
     * non-empty cell.
     */

    sc::MultiDataCellState HasMultipleDataCells( const ScRange& rRange ) const;

    // Spaklines
    /** Returns sparkline at the address if it exists */
    SC_DLLPUBLIC std::shared_ptr<sc::Sparkline> GetSparkline(ScAddress const & rPosition);
    SC_DLLPUBLIC bool HasSparkline(ScAddress const & rPosition);
    SC_DLLPUBLIC sc::Sparkline* CreateSparkline(ScAddress const & rPosition, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup);
    SC_DLLPUBLIC sc::SparklineList* GetSparklineList(SCTAB nTab);
    SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rPosition);

    /**
     * Returns true if the whole range covers one and the same sparkline
     * group and returns the group via out parameter
     */

    SC_DLLPUBLIC bool GetSparklineGroupInRange(ScRange const& rRange, std::shared_ptr<sc::SparklineGroup>& rGroup);
    SC_DLLPUBLIC bool HasOneSparklineGroup(ScRange const& rRange);
    SC_DLLPUBLIC std::shared_ptr<sc::SparklineGroup> SearchSparklineGroup(tools::Guid const& rGuid);

    // Notes
    SC_DLLPUBLIC ScPostIt*       GetNote(const ScAddress& rPos);
    SC_DLLPUBLIC ScPostIt*       GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
    void                         SetNote(const ScAddress& rPos, std::unique_ptr<ScPostIt> pNote);
    void                         SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPostIt> pNote);
    SC_DLLPUBLIC bool            HasNote(const ScAddress& rPos) const;
    bool                         HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
    bool                         HasNote(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const;
    SC_DLLPUBLIC bool            HasColNotes(SCCOL nCol, SCTAB nTab) const;
    SC_DLLPUBLIC bool            HasTabNotes(SCTAB nTab) const;
    bool                         HasNotes() const;
    SC_DLLPUBLIC std::unique_ptr<ScPostIt> ReleaseNote(const ScAddress& rPos);
    SC_DLLPUBLIC ScPostIt*       GetOrCreateNote(const ScAddress& rPos);
    SC_DLLPUBLIC ScPostIt*       CreateNote(const ScAddress& rPos);
    size_t                       GetNoteCount( SCTAB nTab, SCCOL nCol ) const;

    /**
     * Ensure that all note objects have an associated sdr object.  The export
     * code uses sdr objects to export note data.
     */

    void                 CreateAllNoteCaptions();
    void                 ForgetNoteCaptions( const ScRangeList& rRanges, bool bPreserveData );
    CommentCaptionState  GetAllNoteCaptionsState( const ScRangeList& rRanges);

    ScAddress GetNotePosition( size_t nIndex ) const;
    ScAddress GetNotePosition( size_t nIndex, SCTAB nTab ) const;
--> --------------------

--> maximum size reached

--> --------------------

Messung V0.5
C=91 H=91 G=90

¤ Dauer der Verarbeitung: 0.17 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.