LibreOffice Module sc (master) 1
Static Public Member Functions | List of all members
sc::SharedFormulaUtil Class Reference

#include <sharedformula.hxx>

Static Public Member Functions

template<typename Iter >
static void groupFormulaCells (const Iter &itBeg, const Iter &itEnd)
 Group formula cells stored in the passed container. More...
 
static const ScFormulaCellgetSharedTopFormulaCell (const CellStoreType::position_type &aPos)
 Get shared formula top cell from position, if any, else nullptr. More...
 
static bool splitFormulaCellGroup (const CellStoreType::position_type &aPos, sc::EndListeningContext *pCxt)
 Split existing shared formula range at specified position. More...
 
static bool splitFormulaCellGroups (const ScDocument &rDoc, CellStoreType &rCells, std::vector< SCROW > &rBounds)
 Split existing shared formula ranges at specified row positions. More...
 
static bool joinFormulaCells (const CellStoreType::position_type &rPos, ScFormulaCell &rCell1, ScFormulaCell &rCell2)
 See if two specified adjacent formula cells can be merged, and if they can, merge them into the same group. More...
 
static bool joinFormulaCellAbove (const CellStoreType::position_type &aPos)
 Merge with an existing formula group (if any) located immediately above if the cell at specified position is a formula cell, and its formula tokens are identical to that of the above formula group. More...
 
static void unshareFormulaCell (const CellStoreType::position_type &aPos, ScFormulaCell &rCell)
 Turn a shared formula cell into a non-shared one, and split it off from the adjacent formula cell groups. More...
 
static void unshareFormulaCells (const ScDocument &rDoc, CellStoreType &rCells, std::vector< SCROW > &rRows)
 Make specified formula cells non-shared ones, and split them off from their respective adjacent formula cell groups. More...
 
static void startListeningAsGroup (StartListeningContext &rCxt, ScFormulaCell **ppSharedTop)
 Have all formula cells belonging to a group start listening to their references. More...
 

Detailed Description

Definition at line 23 of file sharedformula.hxx.

Member Function Documentation

◆ getSharedTopFormulaCell()

const ScFormulaCell * sc::SharedFormulaUtil::getSharedTopFormulaCell ( const CellStoreType::position_type &  aPos)
static

Get shared formula top cell from position, if any, else nullptr.

Definition at line 20 of file sharedformula.cxx.

References sc::element_type_formula, ScFormulaCell::GetCellGroup(), and ScFormulaCell::IsShared().

Referenced by ScColumn::DetachFormulaCells().

◆ groupFormulaCells()

template<typename Iter >
static void sc::SharedFormulaUtil::groupFormulaCells ( const Iter &  itBeg,
const Iter &  itEnd 
)
inlinestatic

Group formula cells stored in the passed container.

The formula cells in the container are assumed to be all non-shared.

Definition at line 32 of file sharedformula.hxx.

References ScFormulaCell::CompareByTokenArray(), ScFormulaCell::CreateCellGroup(), ScFormulaCell::EqualInvariant, ScFormulaCell::GetCellGroup(), ScFormulaCell::NotEqual, and ScFormulaCell::SetCellGroup().

◆ joinFormulaCellAbove()

bool sc::SharedFormulaUtil::joinFormulaCellAbove ( const CellStoreType::position_type &  aPos)
static

Merge with an existing formula group (if any) located immediately above if the cell at specified position is a formula cell, and its formula tokens are identical to that of the above formula group.

Parameters
aPosposition of cell to examine.
Returns
true if the cells are merged, false otherwise. If the two cells already belong to the same group, it returns false.

Definition at line 212 of file sharedformula.cxx.

References sc::element_type_formula, and joinFormulaCells().

Referenced by ScColumn::AttachFormulaCells(), ScColumn::DeleteRow(), ScColumn::MoveTo(), ScTable::SortReorderByColumn(), and ScColumn::UpdateReferenceOnCopy().

◆ joinFormulaCells()

bool sc::SharedFormulaUtil::joinFormulaCells ( const CellStoreType::position_type &  rPos,
ScFormulaCell rCell1,
ScFormulaCell rCell2 
)
static

See if two specified adjacent formula cells can be merged, and if they can, merge them into the same group.

Parameters
rPosposition object of the first cell
rCell1first cell
rCell2second cell located immediately below the first cell.
Returns
true if the cells are merged, false otherwise. If the two cells already belong to the same group, it returns false.

Definition at line 149 of file sharedformula.cxx.

References ScDocument::AddDelayedFormulaGroupingCell(), ScFormulaCell::aPos, ScFormulaCell::CompareByTokenArray(), ScFormulaCell::CreateCellGroup(), ScFormulaCell::EqualInvariant, ScFormulaCell::GetCellGroup(), ScFormulaCell::GetDocument(), i, ScDocument::IsDelayedFormulaGrouping(), n, ScFormulaCell::NotEqual, ScAddress::Row(), and ScFormulaCell::SetCellGroup().

Referenced by joinFormulaCellAbove(), and ScColumn::JoinNewFormulaCell().

◆ splitFormulaCellGroup()

bool sc::SharedFormulaUtil::splitFormulaCellGroup ( const CellStoreType::position_type &  aPos,
sc::EndListeningContext pCxt 
)
static

Split existing shared formula range at specified position.

The cell at specified position becomes the top cell of the lower shared formula range after this call. This method does nothing if the cell at specified position is not a formula cell.

Parameters
aPosposition of cell to examine.
pCxtcontext to be used, if any, may be nullptr.
Returns
TRUE if there indeed was a split, else FALSE (e.g. split position was top or bottom cell or no formula group).

Definition at line 36 of file sharedformula.cxx.

References ScFormulaCell::aPos, sc::element_type_formula, ScFormulaCell::EndListeningTo(), ScFormulaCell::GetCellGroup(), ScFormulaCell::GetDocument(), ScFormulaCell::GetSharedTopRow(), ScFormulaCell::IsShared(), ScAddress::Row(), ScFormulaCell::SetCellGroup(), ScFormulaCell::SetNeedsListening(), and ScAddress::UNINITIALIZED.

Referenced by ScColumn::DetachFormulaCells(), ScColumn::MoveTo(), and splitFormulaCellGroups().

◆ splitFormulaCellGroups()

bool sc::SharedFormulaUtil::splitFormulaCellGroups ( const ScDocument rDoc,
CellStoreType rCells,
std::vector< SCROW > &  rBounds 
)
static

Split existing shared formula ranges at specified row positions.

Parameters
rCellscell storage container
rBoundsrow positions at which to split existing shared formula ranges. Note that this method will directly modify this parameter to sort and remove duplicates.
Returns
TRUE if there indeed was a split, else FALSE (e.g. split positions were only top or bottom cells or no formula group).

Definition at line 117 of file sharedformula.cxx.

References splitFormulaCellGroup(), and ScDocument::ValidRow().

Referenced by ScColumn::ConvertFormulaToValue(), ScColumn::SplitFormulaGroupByRelativeRef(), ScTable::SplitFormulaGroups(), ScColumn::SwapNonEmpty(), unshareFormulaCells(), and ScColumn::UpdateReference().

◆ startListeningAsGroup()

void sc::SharedFormulaUtil::startListeningAsGroup ( sc::StartListeningContext rCxt,
ScFormulaCell **  ppSharedTop 
)
static

◆ unshareFormulaCell()

void sc::SharedFormulaUtil::unshareFormulaCell ( const CellStoreType::position_type &  aPos,
ScFormulaCell rCell 
)
static

Turn a shared formula cell into a non-shared one, and split it off from the adjacent formula cell groups.

Parameters
aPosposition of cell to examine
rCellformula cell instance

Definition at line 230 of file sharedformula.cxx.

References ScFormulaCell::aPos, ScFormulaCell::GetCellGroup(), ScFormulaCell::GetSharedLength(), ScFormulaCell::GetSharedTopRow(), ScFormulaCell::IsShared(), ScAddress::Row(), and ScFormulaCell::SetCellGroup().

Referenced by ScColumn::DeleteContent(), ScColumn::DetachFormulaCell(), and ScDocumentImport::setFormulaCell().

◆ unshareFormulaCells()

void sc::SharedFormulaUtil::unshareFormulaCells ( const ScDocument rDoc,
CellStoreType rCells,
std::vector< SCROW > &  rRows 
)
static

Make specified formula cells non-shared ones, and split them off from their respective adjacent formula cell groups.

Parameters
rCellscell storage container
rRowsrow positions at which to unshare formula cells.

Definition at line 325 of file sharedformula.cxx.

References ScDocument::MaxRow(), and splitFormulaCellGroups().

Referenced by ScTable::UnshareFormulaCells().


The documentation for this class was generated from the following files: