11#include <document.hxx>
17#include <tokenarray.hxx>
19#include <compiler.hxx>
26#include <numformat.hxx>
32#include <unordered_map>
38 bool mbLatinNumFmtOnly;
40 ColAttr() : mbLatinNumFmtOnly(false) {}
45 std::vector<ColAttr> maCols;
81 if (nCol >= rTab.maCols.size())
82 rTab.maCols.resize(nCol+1);
84 return &rTab.maCols[nCol];
149 mpImpl->mnDefaultScriptNumeric = nScript;
164 if (!
mpImpl->mrDoc.GetTable(rName, nTab))
172 return mpImpl->mrDoc.maTabs.size();
187 mpImpl->mrDoc.SetTabNameOnLoad(nTab, rName);
192 if (!
mpImpl->mrDoc.pDocOptions)
195 mpImpl->mrDoc.pDocOptions->SetDate(nDay, nMonth, nYear);
200 mpImpl->invalidateBlockPositionSet(nTab);
219 pTab->
aCol[rPos.
Col()].ParseString(
220 aCell, rPos.
Row(), rPos.
Tab(), rStr,
mpImpl->mrDoc.GetAddressConvention(), pStringParam);
292 pEditText->NormalizeString(
mpImpl->mrDoc.GetSharedStringPool());
299 const double* pResult )
310 std::unique_ptr<ScFormulaCell> pFC =
311 std::make_unique<ScFormulaCell>(
mpImpl->mrDoc, rPos, rFormula, eGrammar);
313 mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pFC->GetCode());
318 pFC->SetResultDouble(*pResult);
323 rCells.set(pBlockPos->
miCellPos, rPos.
Row(), pFC.release());
328 const OUString& rResult )
339 std::unique_ptr<ScFormulaCell> pFC =
340 std::make_unique<ScFormulaCell>(
mpImpl->mrDoc, rPos, rFormula, eGrammar);
342 mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pFC->GetCode());
345 pFC->SetHybridString(
mpImpl->mrDoc.GetSharedStringPool().intern(rResult));
349 rCells.set(pBlockPos->
miCellPos, rPos.
Row(), pFC.release());
363 std::unique_ptr<ScFormulaCell> pFC =
364 std::make_unique<ScFormulaCell>(
mpImpl->mrDoc, rPos, std::move(pArray));
366 mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pFC->GetCode());
370 rCells.set(pBlockPos->
miCellPos, rPos.
Row(), pFC.release());
385 mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pCell->
GetCode());
414 mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pCell->
GetCode());
417 rCells.set(pBlockPos->
miCellPos, rBasePos.
Row(), pCell);
441 *
t->GetSingleRef() = aRefData;
450 pBlockPos =
mpImpl->getBlockPosition(rBasePos.
Tab(), nCol);
461 *
t->GetSingleRef() = aRefData;
484 OUStringBuffer aFormulaBuf;
485 aFormulaBuf.append(
'=');
494 aFormulaBuf.append(aSep);
496 aFormulaBuf.append(aSep);
497 aRef.
Set(nCol1, nRow1, nTab,
false,
true,
true);
507 aFormulaBuf.append(aSep);
509 aFormulaBuf.append(aSep);
510 aRef.
Set(nCol1, nRow1, nTab,
true,
false,
true);
519 aFormulaBuf.append(aSep);
521 aFormulaBuf.append(aSep);
522 aRef.
Set(nCol1, nRow1 + 1, nTab,
false,
true,
true);
524 aFormulaBuf.append(aSep);
526 aFormulaBuf.append(aSep);
527 aRef.
Set(nCol1 + 1, nRow1, nTab,
true,
false,
true);
536 rDoc,
ScAddress(nCol1, nRow1, nTab), aFormulaBuf.makeStringAndClear(),
539 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
549 for (
SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
554 rColCells.set(pBlockPos->
miCellPos, nRow, pCell);
577 std::vector<double> aCopied(nFillSize, aRefCell.
getDouble());
579 pBlockPos->
miCellPos, rPos.
Row()+1, aCopied.begin(), aCopied.end());
584 std::vector<svl::SharedString> aCopied(nFillSize, *aRefCell.
getSharedString());
586 pBlockPos->
miCellPos, rPos.
Row()+1, aCopied.begin(), aCopied.end());
600 for(
SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol )
602 ColAttr* pColAttr =
mpImpl->getColAttr(nTab, nCol);
604 pColAttr->mbLatinNumFmtOnly = rAttrs.mbLatinNumFmtOnly;
607 pTab->
SetAttrEntries( nColStart, nColEnd, std::move( rAttrs.mvData ));
635class CellStoreInitializer
651 sc::CellTextAttrStoreType::iterator miPos;
655 : maAttrs(rSheetLimits.GetMaxRowCount()), miPos(maAttrs.
begin()), mnScriptNumeric(nScriptNumeric)
668 mpImpl(
std::
make_shared<Impl>(rDocImpl.mrDoc.GetSheetLimits(), mrDocImpl.mnDefaultScriptNumeric))
671 std::shared_ptr<Impl> mpImpl;
673 void operator() (
const sc::CellStoreType::value_type& node)
686 if (p &&
p->mbLatinNumFmtOnly)
693 if (p &&
p->mbLatinNumFmtOnly)
699 bool bNumResOnly =
true;
700 for (; pp != ppEnd; ++pp)
719 std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
720 mpImpl->miPos = mpImpl->maAttrs.set(mpImpl->miPos, node.position, aDefaults.begin(), aDefaults.end());
731 for (; pp != ppEnd; ++pp)
747 mpImpl->maAttrs.swap(rAttrs);
757 for (
auto& rxTab :
mpImpl->mrDoc.maTabs)
764 for (
SCCOL nColIdx = 0; nColIdx < nNumCols; ++nColIdx)
768 mpImpl->mrDoc.finalizeOutlineImport();
784class CellStoreAfterImportBroadcaster
788 CellStoreAfterImportBroadcaster() {}
790 void operator() (
const sc::CellStoreType::value_type& node)
797 for (; pp != ppEnd; ++pp)
799 if ((*pp)->GetCode()->IsRecalcModeMustAfterImport())
813 for (
auto& rxTab :
mpImpl->mrDoc.maTabs)
820 for (
SCCOL nColIdx = 0; nColIdx < nNumCols; ++nColIdx)
827 CellStoreAfterImportBroadcaster aFunc;
841 auto it =
mpImpl->maIsLatinScriptMap.find(nFormat);
842 if (it !=
mpImpl->maIsLatinScriptMap.end())
845 mpImpl->maIsLatinScriptMap.emplace(nFormat, b);
bool ValidTab(SCTAB nTab)
void CellStorageModified()
Called whenever the state of cell array gets modified i.e.
sc::CellTextAttrStoreType maCellTextAttrs
void RegroupFormulaCells(std::vector< ScAddress > *pGroupPos=nullptr)
Regroup formula cells for the entire column.
sc::CellStoreType maCells
void setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible)
void setMatrixCells(const ScRange &rRange, const ScTokenArray &rArray, formula::FormulaGrammar::Grammar eGrammar)
void setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uInt16 nDay)
void initColumn(ScColumn &rCol)
void initForSheets()
Initialize the storage for all sheets after all the sheet instances have been created in the document...
void setMergedCells(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void setEditCell(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
void broadcastRecalcAfterImport()
Broadcast all formula cells that are marked with FormulaTokenArray::IsRecalcModeMustAfterImport() for...
void setStringCell(const ScAddress &rPos, const OUString &rStr)
bool appendSheet(const OUString &rName)
void setDefaultNumericScript(SvtScriptType nScript)
void setFormulaCell(const ScAddress &rPos, const OUString &rFormula, formula::FormulaGrammar::Grammar eGrammar, const double *pResult=nullptr)
void setTableOpCells(const ScRange &rRange, const ScTabOpParam &rParam)
bool isLatinScript(sal_uInt32 nFormat)
small cache for hot call during import
void setSheetName(SCTAB nTab, const OUString &rName)
ScDocumentImport()=delete
void invalidateBlockPositionSet(SCTAB nTab)
static void broadcastRecalcAfterImportColumn(ScColumn &rCol)
SCTAB getSheetCount() const
std::unique_ptr< ScDocumentImportImpl > mpImpl
void setAttrEntries(SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, Attrs &&rAttrs)
Set an array of cell attributes to specified range of columns.
SCTAB getSheetIndex(const OUString &rName) const
void setNumericCell(const ScAddress &rPos, double fVal)
void fillDownCells(const ScAddress &rPos, SCROW nFillSize)
void setAutoInput(const ScAddress &rPos, const OUString &rStr, const ScSetStringParam *pStringParam=nullptr)
void setCellStyleToSheet(SCTAB nTab, const ScStyleSheet &rStyle)
Apply specified cell style to an entire sheet.
void UpdatePageBreaks(SCTAB nTab, const ScRange *pUserArea=nullptr)
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow)
SC_DLLPUBLIC SCTAB GetTableCount() const
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
OUString GetRefString(const ScDocument &rDocument, SCTAB nActTab, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1) const
const ScAddress & GetAddress() const
void Set(const ScAddress &rAdr, bool bNewRelCol, bool bNewRelRow, bool bNewRelTab)
void ApplyStyleArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet &rStyle)
void SetAttrEntries(SCCOL nStartCol, SCCOL nEndCol, std::vector< ScAttrEntry > &&vNewData)
void SetMergedCells(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Temporarily switch on/off auto calculation mode.
static bool isLatinScript(const ScPatternAttr &rPat, ScDocument &rDoc)
Check if the attribute pattern has a number format that only produces latin script output.
Set of column block positions only for one table.
ColumnBlockPosition * getBlockPosition(SCCOL nCol)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void swap(cow_wrapper< T, P > &a, cow_wrapper< T, P > &b)
std::shared_ptr< T > make_shared(Args &&... args)
enumrange< T >::Iterator begin(enumrange< T >)
const mdds::mtv::element_t element_type_formula
mdds::mtv::soa::multi_type_vector< CellFunc, CellStoreTrait > CellStoreType
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
mdds::mtv::soa::multi_type_vector< CTAttrFunc > CellTextAttrStoreType
const mdds::mtv::element_t element_type_empty
Store arbitrary cell value of any kind.
ScFormulaCell * releaseFormula()
const svl::SharedString * getSharedString() const
EditTextObject * releaseEditText()
ScFormulaCell * getFormula() const
ColAttr * getColAttr(size_t nTab, size_t nCol)
std::unordered_map< sal_uInt32, bool > maIsLatinScriptMap
sc::StartListeningContext maListenCxt
ScDocumentImportImpl(ScDocument &rDoc)
sc::ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
bool isValid(size_t nTab, size_t nCol)
SvtScriptType mnDefaultScriptNumeric
void invalidateBlockPositionSet(SCTAB nTab)
std::vector< TabAttr > maTabAttrs
std::vector< sc::TableColumnBlockPositionSet > maBlockPosSet
This is very similar to ScCellValue, except that it references the original value instead of copying ...
const svl::SharedString * getSharedString() const
Store parameters used in the ScDocument::SetString() method.
bool mbCheckLinkFormula
When true and the string results in a compiled formula, check the formula tokens for presence of func...
Single reference (one address) into the sheet.
void SetAddress(const ScSheetLimits &rLimits, const ScAddress &rAddr, const ScAddress &rPos)
void SetRowRel(bool bVal)
void SetTabRel(bool bVal)
void InitFlags()
No default ctor, because used in ScRawToken union, set InitFlags!
void SetColRel(bool bVal)
Parameter for data table aka multiple operations.
ScRefAddress aRefFormulaEnd
ScRefAddress aRefFormulaCell
SvtScriptType mnScriptType
Store position data for column array storage.
CellStoreType::iterator miCellPos