/* -*- 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 .
*/
enumclass SvtScriptType : sal_uInt8; enumclass ScMF; enumclass FormulaError : sal_uInt16; enumclass CharCompressType; enumclass 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; enumclass ScDBDataPortion; enumclass ScSheetEventId; class BitmapEx; class ScColumnsRange; struct ScFilterEntries; typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes; struct ScDataAreaExtras; enumclass ScConditionMode;
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. enumclass SheetGeomType
{
SIZES, // Column widths or row heights.
HIDDEN, // Hidden columns/rows.
FILTERED, // Filtered columns/rows.
GROUPS // Grouping of columns/rows.
};
// 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;
};
public: enumclass 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;
// 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<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
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;
std::shared_mutex mScLookupMutex; // protection for thread-unsafe parts of handling ScLookup
std::unique_ptr<ScSortedRangeCacheMap> mxScSortedRangeCache; // cache for unsorted lookups
staticconst 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
// 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
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.
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;
/** * 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.
/** 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, constbool bGlobalNamesToLocal, constbool bUsedByFormula ) const;
/** * Call this immediately before updating all named ranges.
*/
SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, ScRangeName>& 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& rPos, const 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;
/** 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();
/** 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& 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 );
/** * 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);
/** * 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);
/** * 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 );
/** 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;
/** * 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);
void CheckVectorizationState(); void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt ); void SetDirty( const ScRange&, bool bIncludeEmptyCells ); void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp void InterpretDirtyCells( const ScRangeList& rRanges ); // Interprets cells that have NeedsInterpret(), i.e. the same like calling MaybeInterpret() on them. // Returns false if some couldn't be interpreted (i.e. they still have NeedsInterpret()). // Useful to ensure that the given cells will not need interpreting. bool InterpretCellsIfNeeded( const ScRangeList& rRanges );
SC_DLLPUBLIC void CalcAll();
SC_DLLPUBLIC void CalcAfterLoad( bool bStartListening = true ); void CompileAll(); void CompileXML();
/** * Re-compile formula cells with error. * * @param nErrCode specified error code to match. Only those cells with * this error code will be re-compiled. If this value is * 0, cells with any error values will be re-compiled. * * @return true if at least one cell is re-compiled, false if no cells are * re-compiled.
*/ bool CompileErrorCells(FormulaError nErrCode);
/** Creates a ScLookupCache cache for the range if it
doesn't already exist. */
ScLookupCache & GetLookupCache( const ScRange & rRange, ScInterpreterContext* pContext );
ScSortedRangeCache & GetSortedRangeCache( const ScRange & rRange, const ScQueryParam& param,
ScInterpreterContext* pContext, bool bNewSearchFunction,
sal_uInt8 nSortedBinarySearch = 0x00 ); /** Only ScLookupCache dtor uses RemoveLookupCache(), do
not use elsewhere! */ void RemoveLookupCache( ScLookupCache & rCache ); void RemoveSortedRangeCache( ScSortedRangeCache & rCache ); /** Zap all caches. */ void ClearLookupCaches();
// calculate automatically
SC_DLLPUBLIC void SetAutoCalc( bool bNewAutoCalc );
SC_DLLPUBLIC bool GetAutoCalc() const { return bAutoCalc; } // calculate automatically in/from/for ScDocShell disabled void SetAutoCalcShellDisabled( bool bNew ) { bAutoCalcShellDisabled = bNew; } bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; } // ForcedFormulas are to be calculated void SetForcedFormulaPending( bool bNew ) { bForcedFormulaPending = bNew; } bool IsForcedFormulaPending() const { return bForcedFormulaPending; } // if CalcFormulaTree() is currently running bool IsCalculatingFormulaTree() const { return bCalculatingFormulaTree; } /// If set, joining cells into shared formula groups will be delayed until reset again /// (RegroupFormulaCells() will be called as needed). void DelayFormulaGrouping( bool delay ); bool IsDelayedFormulaGrouping() const { returnbool(pDelayedFormulaGrouping); } /// To be used only by SharedFormulaUtil::joinFormulaCells(). void AddDelayedFormulaGroupingCell( const ScFormulaCell* cell ); /// If set, ScColumn::StartListeningFormulaCells() calls may be delayed using /// CanDelayStartListeningFormulaCells() until reset again, at which point the function will /// be called as necessary. void EnableDelayStartListeningFormulaCells( ScColumn* column, bool delay ); bool IsEnabledDelayStartListeningFormulaCells( ScColumn* column ) const; /// If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed /// later. If false is returned, it needs to be done explicitly. bool CanDelayStartListeningFormulaCells( ScColumn* column, SCROW row1, SCROW row2 ); /// If set, cells will not delete their empty broadcasters, avoiding possible extensive mdds /// vector changes. Disabling delay will collect and delete all empty broadcasters. void EnableDelayDeletingBroadcasters(bool set); bool IsDelayedDeletingBroadcasters() const { return bDelayedDeletingBroadcasters; }
This is not the actually used area within the selection, but the bounds of the sheet's data area instead.
@returns TRUE if the area passed intersected the data area, FALSE if not, in which case the values obtained may be out of bounds, not in order or unmodified. TRUE does not mean that there actually is any data within the selection.
*/ bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
/** Shrink a range to only include used data area.
@param o_bShrunk Out parameter, true if area was shrunk, false if not. @param bColumnsOnly If TRUE, shrink only by columns, not rows. @param bStickyTopRow If TRUE, do not adjust the top row. @param bStickyLeftCol If TRUE, do not adjust the left column. @param pDataAreaExtras Consider additional area attributes like cell formatting, cell notes and draw objects. The possibly larger area than the actual cell content data area is returned within the struct.
@returns true if there is any data, false if not.
*/ bool ShrinkToUsedDataArea( bool& o_bShrunk,
SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly, bool bStickyTopRow = false, bool bStickyLeftCol = false,
ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
/** * Return the last non-empty row position in given columns that's no * greater than the initial last row position, or 0 if the columns are * empty. A negative value is returned if the given sheet or column * positions are invalid. * * <p>It starts from the specified last row position, and finds the first * non-empty row position in the upward direction if the start row * position is empty.</p>
*/
SC_DLLPUBLIC SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
/** * Return the smallest area containing at least all contiguous cells * having data. This area is a square containing also empty cells. It may * shrink or extend the area given as input Flags as modifiers: * * @param bIncludeOld when true, ensure that the returned area contains at * least the initial area even if the actual data area * is smaller than the initial area. * * @param bOnlyDown when true, extend / shrink the data area only in a * downward direction i.e. only modify the end row * position.
*/
SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
SCCOL& rEndCol, SCROW& rEndRow, bool bIncludeOld, bool bOnlyDown ) const;
/** * Return the extended area containing at least all contiguous cells * having background color.
*/
SC_DLLPUBLIC void GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
SCCOL& rEndCol, SCROW& rEndRow ) const;
/** * Returns true if there is a non-empty subrange in the range given as input. * In that case it also modifies rRange to largest subrange that does not * have empty col/row inrange-segments in the beginning/end. * It returns false if rRange is completely empty and in this case rRange is * left unmodified.
*/ bool GetDataAreaSubrange(ScRange& rRange) const;
/// Return the number of columns / rows that should be visible for the tiled rendering.
SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const;
/** * Find the maximum column position that contains printable data for the * specified row range. The final column position must be equal or less * than the initial value of rEndCol.
*/ void ExtendPrintArea( OutputDevice* pDev, SCTAB nTab,
SCCOL nStartCol, SCROW nStartRow,
SCCOL& rEndCol, SCROW nEndRow ) const;
SC_DLLPUBLIC bool IsEmptyData(SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const; // I think this returns the number of empty cells starting from the given direction.
SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
ScDirection eDir );
/** * Copy only raw cell values to another document. Formula cells are * converted to raw cells. No formatting info are copied except for * number formats. * * @param rSrcRange source range in the source document * @param nDestTab table in the clip document to copy to. * @param rDestDoc document to copy to
*/
SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument& rDestDoc);
/** * Copy only cell, nothing but cell to another document. * * @param rSrcPos source cell position * @param rDestPos destination cell position * @param rDestDoc destination document
*/ void CopyCellToDocument( const ScAddress& rSrcPos, const ScAddress& rDestPos, ScDocument& rDestDoc );
/** * Paste data from a clipboard document into this document. * * @param rDestRange destination range. * @param pClipDoc pointer to the clipboard document to copy data from. * @param bSkipEmptyCells if this flag is set, empty cells in the source * range in the clipboard document will not overwrite * the target destination cells. * @param pDestRanges If pDestRanges is given it overrides rDestRange, where * rDestRange becomes the overall encompassing range.
*/
SC_DLLPUBLIC void CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
ScDocument* pRefUndoDoc, ScDocument* pClipDoc, bool bResetCut = true, bool bAsLink = false, bool bIncludeFiltered = true, bool bSkipEmptyCells = false, const ScRangeList* pDestRanges = nullptr );
/** To be called at the clipboard document when closing a document that is the current clipboard source to decouple things from the originating document. Done in ScDocument dtor after determining IsClipboardSource().
*/ void ClosingClipboardSource();
// determine Col/Row of subsequent calls // (e.g. not found from the beginning, or subsequent tables) // meaning of explanation in "()" was already unclear in German void GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
SCCOL& rCol, SCROW& rRow );
/** * Given the height i.e. total vertical distance from the top of the sheet * grid, return the first visible row whose top position is below the * specified height.
*/
SCROW GetRowForHeight( SCTAB nTab, tools::Long nHeight ) const; /** * Given the height i.e. total vertical distance from the top of the sheet * grid, return the first visible row whose top position is below the * specified height and after the specified row. * Note that this variant uses pixels, not twips. * @param nStartRow the row to start searching at. * @param rStartRowHeightPx this is both the height at nStartRow, and returns the height of the first row * which has height > nHeight
*/
SCROW GetRowForHeightPixels( SCTAB nTab, SCROW nStartRow, tools::Long& rStartRowHeightPx, tools::Long nHeightPx, double fPPTY ) const;
tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
SC_DLLPUBLIC tools::Long GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
SC_DLLPUBLIC tools::Long GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
/** * Write all column row flags to table's flag data, because not all column * row attributes are stored in the flag data members. This is necessary * for ods export.
*/ void SyncColRowFlags();
/// @return the index of the last row with any set flags (auto-pagebreak is ignored).
SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const;
/// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
SCCOL GetLastChangedColFlagsWidth( SCTAB nTab ) const; /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
SCROW GetLastChangedRowFlagsWidth( SCTAB nTab ) const;
// returns whether to export a Default style for this col or not // nDefault is set to one position in the current row where the Default style is void GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault);
/** * Get a list of unique strings to use in filtering criteria. The string * values are sorted, and there are no duplicate values in the list. The * data range to use to populate the filter entries is inferred from the * database range that contains the specified cell position.
*/ void GetFilterEntries( SCCOL nCol, SCROW nRow,
SCTAB nTab, ScFilterEntries& rFilterEntries );
/** * Set an array of numerical formula results to a group of contiguous * formula cells. * * @param rTopPos position of the top formula cell of a group. * @param pResults array of numeric results. * @param nLen length of numeric results.
*/ void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, constdouble* pResults, size_t nLen );
/** * Transfer a series of contiguous cell values from specified position to * the passed container. The specified segment will become empty after the * transfer.
*/ void TransferCellValuesTo( const ScAddress& rTopPos, size_t nLen, sc::CellValues& rDest ); void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc );
/** * Check the integrity of the internal table state. Useful from testing * code. It throws an exception upon first failure. * * Feel free to add more checks as needed.
*/ void CheckIntegrity( SCTAB nTab ) const;
Used to start and stop listening on a sane range. Both o_rRange and o_bEntirelyOutOfBounds are set only if needed and don't have to be initialized by the caller.
@param o_bEntirelyOutOfBounds <TRUE/> if both sheets in the range point outside the available sheet range, in which case no adjustment is done and o_rRange is not modified.
@return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds was set <TRUE/>. <FALSE/> if rRange was within the available sheets.
*/ bool LimitRangeToAvailableSheets( const ScRange& rRange, ScRange& o_rRange, bool& o_bEntirelyOutOfBounds ) const;
/** * Calculate formula cells that are on the formula tree either partially, * or in full. * * @param bOnlyForced when true, it only calculates those formula cells * that are marked "recalc forced". * @param bProgressBar whether or not to use progress bar. * @param bSetAllDirty when true, it marks all formula cells currently on * the formula tree dirty, which forces all of them to * be recalculated. When false, only those cells * that are marked dirty prior to this call get * recalculated.
*/
SC_DLLPUBLIC void CalcFormulaTree( bool bOnlyForced = false, bool bProgressBar = true, boolbSetAllDirty = true ); void ClearFormulaTree(); void AppendToFormulaTrack( ScFormulaCell* pCell ); void RemoveFromFormulaTrack( ScFormulaCell* pCell ); void TrackFormulas( SfxHintId nHintId = SfxHintId::ScDataChanged ); void SetTrackFormulasPending() { mbTrackFormulasPending = true; } bool IsTrackFormulasPending() const { return mbTrackFormulasPending; } void FinalTrackFormulas( SfxHintId nHintId ); bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas; } inlinebool IsInFormulaTree( const ScFormulaCell* pCell ) const; inlinebool IsInFormulaTrack( const ScFormulaCell* pCell ) const;
HardRecalcState GetHardRecalcState() const { return eHardRecalcState; } void SetHardRecalcState( HardRecalcState eVal ) { eHardRecalcState = eVal; } void StartAllListeners(); void StartNeededListeners(); void StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet );
SC_DLLPUBLIC void StartAllListeners( const ScRange& rRange );
/** Maximum string length of a column, e.g. for dBase export. @return String length in octets (!) of the destination encoding. In case of non-octet encodings (e.g. UCS2) the length in code
points times sizeof(sal_Unicode) is returned. */
sal_Int32 GetMaxStringLen( SCTAB nTab, SCCOL nCol,
SCROW nRowStart, SCROW nRowEnd,
rtl_TextEncoding eCharSet ) const; /** Maximum string length of numerical cells of a column, e.g. for dBase export. @return String length in characters (!) including the decimal
separator, and the decimal precision needed. */
sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
SCTAB nTab, SCCOL nCol,
SCROW nRowStart, SCROW nRowEnd ) const;
//! only for import filter, deletes any existing ChangeTrack via //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
SC_DLLPUBLIC void SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack );
/** Should only be GRAM_PODF or GRAM_ODFF. */ void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar );
formula::FormulaGrammar::Grammar GetStorageGrammar() const { return eStorageGrammar; }
/** * Make specified formula cells non-grouped. * * @param nTab sheet index * @param nCol column index * @param rRows list of row indices at which formula cells are to be * unshared. This call sorts the passed row indices and * removes duplicates, which is why the caller must pass it * as reference.
*/ void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows ); void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
SC_DLLPUBLIC void RegroupFormulaCells( const ScRange& range );
/** * Call this before any operations that might trigger one or more formula * cells to get calculated.
*/ void PrepareFormulaCalc();
/** * Make sure all of the formula cells in the specified range have been * fully calculated. This method only re-calculates those formula cells * that have been flagged dirty. In case of formula-groups, this calculates * only the dirty subspans along with the dependents in the same way * recursively. * * @param rRange range in which to potentially calculate the formula * cells. * @param bSkipRunning flag to skip evaluation of formula-cells that are * marked as already being evaluated. * @return true if at least one formula-cell in the specified range was dirty * else returns false.
*/
SC_DLLPUBLIC bool EnsureFormulaCellResults( const ScRange& rRange, bool bSkipRunning = false );
// Returns the given column range, first allocating all the columns if necessary.
SC_DLLPUBLIC ScColumnsRange GetWritableColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd); // Returns a column range, clamped to the allocated columns.
SC_DLLPUBLIC ScColumnsRange GetAllocatedColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const; // Returns the given range, without any adjustments. One of the variants above may return // a smaller range (better performance) if the use case is known.
SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
/** * Serializes the specified sheet's geometry data. * * @param nTab is the index of the sheet to operate on. * @param bColumns - if true it dumps the data for columns, else it does for rows. * @param eGeomType indicates the type of data to be dumped for rows/columns. * @return the serialization of the specified sheet's geometry data as an OString.
*/
OString dumpSheetGeomData(SCTAB nTab, bool bColumns, SheetGeomType eGeomType);
/** * Use this class as a locale variable to merge number formatter from * another document, and set NULL pointer to pFormatExchangeList when * done.
*/ class NumFmtMergeHandler
{ public: explicit NumFmtMergeHandler(ScDocument& rDoc, const ScDocument& rSrcDoc);
~NumFmtMergeHandler();
/** * Instantiate this to ensure that subsequent modification of * the document will cause an assertion failure while this is * in-scope.
*/ struct ScMutationDisable
{ #ifndef NDEBUG
ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags)
: mnFlagRestore(rDocument.mnMutationGuardFlags)
, mrDocument(rDocument)
{
assert((mnFlagRestore & nFlags) == 0);
mrDocument.mnMutationGuardFlags |= static_cast<size_t>(nFlags);
}
~ScMutationDisable()
{
mrDocument.mnMutationGuardFlags = mnFlagRestore;
}
size_t mnFlagRestore;
ScDocument& mrDocument; #else
ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags)
{
(void)rDocument; (void)nFlags;
} #endif
};
/** * A pretty assertion that checks that the relevant bits in * the @nFlags are not set on the document at entry and exit. * * Its primary use is for debugging threading. As such, an * @ScMutationDisable is created to forbid mutation, and this * condition is then asserted on at prominent sites that * mutate @nFlags.
*/ struct ScMutationGuard
{ #ifndef NDEBUG
ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags)
: mnFlags(static_cast<size_t>(nFlags))
, mrDocument(rDocument)
{
assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0);
}
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.72Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-05-05)
¤
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.