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());
389 sc::CellStoreType::position_type aPos = rCells.position(rPos.
Row());
392 ScFormulaCell*
p = sc::formula_block::at(*aPos.first->data, aPos.second);
422 mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pCell->
GetCode());
425 rCells.set(pBlockPos->
miCellPos, rBasePos.
Row(), pCell);
449 *
t->GetSingleRef() = aRefData;
458 pBlockPos =
mpImpl->getBlockPosition(rBasePos.
Tab(), nCol);
469 *
t->GetSingleRef() = aRefData;
492 OUStringBuffer aFormulaBuf(
"="
504 aRef.
Set(nCol1, nRow1, nTab,
false,
true,
true);
517 aRef.
Set(nCol1, nRow1, nTab,
true,
false,
true);
529 aRef.
Set(nCol1, nRow1 + 1, nTab,
false,
true,
true);
534 aRef.
Set(nCol1 + 1, nRow1, nTab,
true,
false,
true);
543 rDoc,
ScAddress(nCol1, nRow1, nTab), aFormulaBuf.makeStringAndClear(),
546 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
556 for (
SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
561 rColCells.set(pBlockPos->
miCellPos, nRow, pCell);
584 std::vector<double> aCopied(nFillSize, aRefCell.
getDouble());
586 pBlockPos->
miCellPos, rPos.
Row()+1, aCopied.begin(), aCopied.end());
591 std::vector<svl::SharedString> aCopied(nFillSize, *aRefCell.
getSharedString());
593 pBlockPos->
miCellPos, rPos.
Row()+1, aCopied.begin(), aCopied.end());
607 for(
SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol )
609 ColAttr* pColAttr =
mpImpl->getColAttr(nTab, nCol);
611 pColAttr->mbLatinNumFmtOnly = rAttrs.mbLatinNumFmtOnly;
614 pTab->
SetAttrEntries( nColStart, nColEnd, std::move( rAttrs.mvData ));
642class CellStoreInitializer
658 sc::CellTextAttrStoreType::iterator miPos;
662 : maAttrs(rSheetLimits.GetMaxRowCount()), miPos(maAttrs.
begin()), mnScriptNumeric(nScriptNumeric)
675 mpImpl(
std::
make_shared<Impl>(rDocImpl.mrDoc.GetSheetLimits(), mrDocImpl.mnDefaultScriptNumeric))
678 std::shared_ptr<Impl> mpImpl;
680 void operator() (
const sc::CellStoreType::value_type& node)
693 if (p &&
p->mbLatinNumFmtOnly)
700 if (p &&
p->mbLatinNumFmtOnly)
706 bool bNumResOnly =
true;
707 for (; pp != ppEnd; ++pp)
726 std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
727 mpImpl->miPos = mpImpl->maAttrs.set(mpImpl->miPos, node.position, aDefaults.begin(), aDefaults.end());
738 for (; pp != ppEnd; ++pp)
754 mpImpl->maAttrs.swap(rAttrs);
764 for (
auto& rxTab :
mpImpl->mrDoc.maTabs)
771 for (
SCCOL nColIdx = 0; nColIdx < nNumCols; ++nColIdx)
775 mpImpl->mrDoc.finalizeOutlineImport();
791class CellStoreAfterImportBroadcaster
795 CellStoreAfterImportBroadcaster() {}
797 void operator() (
const sc::CellStoreType::value_type& node)
804 for (; pp != ppEnd; ++pp)
806 if ((*pp)->GetCode()->IsRecalcModeMustAfterImport())
820 for (
auto& rxTab :
mpImpl->mrDoc.maTabs)
827 for (
SCCOL nColIdx = 0; nColIdx < nNumCols; ++nColIdx)
834 CellStoreAfterImportBroadcaster aFunc;
848 auto it =
mpImpl->maIsLatinScriptMap.find(nFormat);
849 if (it !=
mpImpl->maIsLatinScriptMap.end())
852 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< CellStoreTraits > CellStoreType
Cell container.
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
mdds::mtv::soa::multi_type_vector< CellTextAttrTraits > CellTextAttrStoreType
Cell text attribute container.
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