21#include <document.hxx>
23#include <tokenarray.hxx>
41#include <osl/file.hxx>
63#include <com/sun/star/document/MacroExecMode.hpp>
64#include <com/sun/star/document/UpdateDocMode.hpp>
70using ::std::unique_ptr;
71using ::com::sun::star::uno::Any;
79#define SRCDOC_LIFE_SPAN 30000
80#define SRCDOC_SCAN_INTERVAL 1000*30
84class TabNameSearchPredicate
87 explicit TabNameSearchPredicate(
const OUString& rSearchName) :
99 OUString maSearchName;
102class FindSrcFileByName
105 explicit FindSrcFileByName(
const OUString& rMatchName) :
106 mrMatchName(rMatchName)
116 const OUString& mrMatchName;
119class NotifyLinkListener
134struct UpdateFormulaCell
158class RemoveFormulaCell
162 void operator() (pair<const sal_uInt16, ScExternalRefManager::RefCellSet>& r)
const
170class ConvertFormulaToStatic
173 explicit ConvertFormulaToStatic(
ScDocument* pDoc) : mpDoc(pDoc) {}
184 mpDoc->SetValue(aPos, pCell->
GetValue());
202bool hasRefsToSrcDoc(
ScRangeData& rData, sal_uInt16 nFileId)
212 if (!
p->IsExternalRef())
215 if (
p->GetIndex() == nFileId)
221class EraseRangeByIterator
225 explicit EraseRangeByIterator(
ScRangeName& rRanges) : mrRanges(rRanges) {}
236void removeRangeNamesBySrcDoc(
ScRangeName& rRanges, sal_uInt16 nFileId)
239 vector<ScRangeName::const_iterator>
v;
240 for (; itr != itrEnd; ++itr)
242 if (hasRefsToSrcDoc(*itr->second, nFileId))
245 for_each(
v.begin(),
v.end(), EraseRangeByIterator(rRanges));
251 : mbReferenced( true )
263 maCachedRanges.RemoveAll();
269 mbReferenced = bReferenced;
280 RowsDataType::iterator itrRow = maRows.find(nRow);
281 if (itrRow == maRows.end())
284 pair<RowsDataType::iterator, bool> res = maRows.emplace(
299 rRow.emplace(nCol, aCell);
301 setCachedCell(nCol, nRow);
306 RowsDataType::const_iterator itrTable = maRows.find(nRow);
307 if (itrTable == maRows.end())
310 return getEmptyOrNullToken(nCol, nRow);
314 RowDataType::const_iterator itrRow = rRowData.find(nCol);
315 if (itrRow == rRowData.end())
318 return getEmptyOrNullToken(nCol, nRow);
321 const Cell& rCell = itrRow->second;
330 RowsDataType::const_iterator itrRow = maRows.find(nRow);
331 return itrRow != maRows.end();
334template<
typename P >
338 aRows.reserve(maRows.size());
339 for (
const auto& rEntry : maRows)
340 if (predicate(rEntry))
341 aRows.push_back(rEntry.first);
344 ::std::sort(aRows.begin(), aRows.end());
351 [nLow, nHigh](std::pair<SCROW, RowDataType> rEntry) {
return (nLow <= rEntry.first && rEntry.first <= nHigh); });
356 getAllRows(rRows, [](std::pair<SCROW, RowDataType>) {
return true; } );
361 ::std::pair< SCROW, SCROW > aRange( 0, 0 );
362 if( !maRows.empty() )
365 auto itMinMax = std::minmax_element(maRows.begin(), maRows.end(),
366 [](
const RowsDataType::value_type&
a,
const RowsDataType::value_type& b) { return a.first < b.first; });
367 aRange.first = itMinMax.first->first;
368 aRange.second = itMinMax.second->first + 1;
373template<
typename P >
376 RowsDataType::const_iterator itrRow = maRows.find(nRow);
377 if (itrRow == maRows.end())
383 aCols.reserve(rRowData.size());
384 for (
const auto& rCol : rRowData)
386 aCols.push_back(rCol.first);
389 ::std::sort(aCols.begin(), aCols.end());
395 getAllCols(nRow, rCols,
396 [nLow, nHigh](std::pair<SCCOL, Cell> rCol) {
return nLow <= rCol.first && rCol.first <= nHigh; } );
401 getAllCols(nRow, rCols, [](std::pair<SCCOL, Cell>) {
return true; } );
406 ::std::pair< SCCOL, SCCOL > aRange( 0, 0 );
408 RowsDataType::const_iterator itrRow = maRows.find( nRow );
409 if (itrRow == maRows.end())
414 if( !rRowData.empty() )
417 auto itMinMax = std::minmax_element(rRowData.begin(), rRowData.end(),
418 [](
const RowDataType::value_type&
a,
const RowDataType::value_type& b) { return a.first < b.first; });
419 aRange.first = itMinMax.first->first;
420 aRange.second = itMinMax.second->first + 1;
427 for (
const auto& rRow : maRows)
430 for (
const auto& rCol : rRowData)
432 const Cell& rCell = rCol.second;
440 return maCachedRanges.Contains(
ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0));
445 setCachedCellRange(nCol, nRow, nCol, nRow);
450 ScRange aRange(nCol1, nRow1, 0, nCol2, nRow2, 0);
451 maCachedRanges.Join(aRange);
461 return maCachedRanges.Contains(
ScRange(nCol, nRow, 0, nCol, nRow, 0));
467 if (isInCachedRanges(nCol, nRow))
476 maUpperName(
std::move(aUpper)), maRealName(
std::move(aReal))
496 DocDataType::const_iterator itrDoc =
maDocs.find(nFileId);
497 if (itrDoc ==
maDocs.end())
503 const DocItem& rDoc = itrDoc->second;
518 DocDataType::const_iterator itrDoc =
maDocs.find(nFileId);
519 if (itrDoc ==
maDocs.end())
525 const DocItem& rDoc = itrDoc->second;
536 sal_uInt16 nFileId,
const OUString& rTabName,
SCCOL nCol,
SCROW nRow, sal_uInt32* pnFmtIndex)
540 DocDataType::const_iterator itrDoc =
maDocs.find(nFileId);
541 if (itrDoc ==
maDocs.end())
547 const DocItem& rDoc = itrDoc->second;
562 return pTableData->getCell(nCol, nRow, pnFmtIndex);
566 sal_uInt16 nFileId,
const OUString& rTabName,
const ScRange& rRange)
570 DocDataType::iterator itrDoc =
maDocs.find(nFileId);
571 if (itrDoc ==
maDocs.end())
575 DocItem& rDoc = itrDoc->second;
590 size_t nTabFirstId = itrTabId->second;
591 size_t nTabLastId = nTabFirstId + nTab2 - nTab1;
592 if (nTabLastId >= rDoc.
maTables.size())
596 ScRange aCacheRange( nCol1, nRow1,
static_cast<SCTAB>(nTabFirstId), nCol2, nRow2,
static_cast<SCTAB>(nTabLastId));
598 RangeArrayMap::const_iterator itrRange = rDoc.
maRangeArrays.find( aCacheRange);
601 return itrRange->second;
603 std::unique_ptr<ScRange> pNewRange;
605 bool bFirstTab =
true;
606 for (
size_t nTab = nTabFirstId; nTab <= nTabLastId; ++nTab)
612 SCCOL nDataCol1 = nCol1, nDataCol2 = nCol2;
613 SCROW nDataRow1 = nRow1, nDataRow2 = nRow2;
615 if (!pTab->isRangeCached(nDataCol1, nDataRow1, nDataCol2, nDataRow2))
621 SCSIZE nMatrixColumns =
static_cast<SCSIZE>(nDataCol2-nDataCol1+1);
622 SCSIZE nMatrixRows =
static_cast<SCSIZE>(nDataRow2-nDataRow1+1);
627 pTab->getAllRows(aRows, nDataRow1, nDataRow2);
638 SCSIZE nMatCols, nMatRows;
639 xMat->GetDimensions( nMatCols, nMatRows);
640 if (nMatCols != nMatrixColumns || nMatRows != nMatrixRows)
649 else if ((nCol1 == 0 && nCol2 ==
MAXCOL) || (nRow1 == 0 && nRow2 ==
MAXROW))
651 nDataRow1 = aRows.front();
652 nDataRow2 = aRows.back();
653 SCCOL nMinCol = std::numeric_limits<SCCOL>::max();
654 SCCOL nMaxCol = std::numeric_limits<SCCOL>::min();
655 for (
const auto& rRow : aRows)
658 pTab->getAllCols(rRow, aCols, nDataCol1, nDataCol2);
661 nMinCol = std::min( nMinCol, aCols.front());
662 nMaxCol = std::max( nMaxCol, aCols.back());
669 nMatrixColumns =
static_cast<SCSIZE>(nMaxCol-nMinCol+1);
670 nMatrixRows =
static_cast<SCSIZE>(nDataRow2-nDataRow1+1);
671 xMat =
new ScMatrix( nMatrixColumns, nMatrixRows);
672 xMat->GetDimensions( nMatCols, nMatRows);
673 if (nMatCols == nMatrixColumns && nMatRows == nMatrixRows)
686 for (
SCROW nRow : aRows)
689 pTab->getAllCols(nRow, aCols, nDataCol1, nDataCol2);
690 for (
SCCOL nCol : aCols)
692 TokenRef pToken = pTab->getCell(nCol, nRow);
697 SCSIZE nC = nCol - nDataCol1, nR = nRow - nDataRow1;
698 switch (pToken->GetType())
701 xMat->PutDouble(pToken->GetDouble(), nC, nR);
704 xMat->PutString(pToken->GetString(), nC, nR);
713 pArray->AddOpCode(
ocSep);
717 pArray = std::make_shared<ScTokenArray>(
mrDoc);
718 pArray->AddToken(aToken);
723 pNewRange.reset(
new ScRange(nDataCol1, nDataRow1, nTab, nDataCol2, nDataRow2, nTab));
725 pNewRange->ExtendTo(
ScRange(nDataCol1, nDataRow1, nTab, nDataCol2, nDataRow2, nTab));
730 if (pNewRange && *pNewRange != aCacheRange)
745 RangeNameMap::const_iterator itr = rMap.find(
747 if (itr == rMap.end())
763 rMap.emplace(aUpperName, pArray);
777 return rMap.count(aUpperName) > 0;
813 pTableData = std::make_shared<Table>();
815 pTableData->setCell(nCol, nRow, pToken, nFmtIndex);
816 pTableData->setCachedCell(nCol, nRow);
835 const OUString& rFirstTabName = rData.front().maTableName;
836 TableNameIndexMap::const_iterator itrTabName = rDoc.
findTableNameIndex( rFirstTabName);
843 size_t nTabFirstId = itrTabName->second;
846 size_t i = nTabFirstId;
847 for (
const auto& rItem : rData)
851 pTabData = std::make_shared<Table>();
854 SCSIZE nMatCols, nMatRows;
855 pMat->GetDimensions( nMatCols, nMatRows);
874 pMat->ExecuteOperation(std::pair<size_t, size_t>(0, 0),
875 std::pair<size_t, size_t>(nRow2-nRow1, nCol2-nCol1),
876 std::move(aDoubleFunc), std::move(aBoolFunc), std::move(aStringFunc), std::move(aEmptyFunc));
878 pTabData->setCachedCellRange(nCol1, nRow1, nCol2, nRow2);
884 SAL_WARN(
"sc.ui",
"ScExternalRefCache::setCellRangeData - matrix size mismatch");
885 if (nMatCols != 1 || nMatRows != 1)
886 SAL_WARN(
"sc.ui",
"ScExternalRefCache::setCellRangeData - not a one element matrix");
890 SAL_WARN(
"sc.ui",
"ScExternalRefCache::setCellRangeData - matrix error value is " <<
static_cast<int>(nErr) <<
891 (nErr == FormulaError::MatrixSize ?
", ok" :
", not ok"));
898 ScRange aCacheRange( nCol1, nRow1,
static_cast<SCTAB>(nTabFirstId), nCol2, nRow2,
static_cast<SCTAB>(nTabLastId));
914 ScExternalRefCache::TableNameIndexMap::const_iterator itr = rMap.find(rName);
915 if (itr == rMap.end())
918 rIndex = itr->second;
924 ScExternalRefCache::TableNameIndexMap::const_iterator itr =
findTableNameIndex(rTabName);
928 rIndex = itr->second;
933OUString getFirstSheetName()
944 const OUString& rBaseName)
950 size_t n = rTabNames.size();
955 vector<TableName> aNewTabNames;
956 aNewTabNames.reserve(
n);
957 for (
const auto& rTabName : rTabNames)
960 aNewTabNames.push_back(aNameItem);
966 vector<TableTypeRef> aNewTables(
n);
967 for (
size_t i = 0;
i <
n; ++
i)
979 for (
size_t i = 0;
i <
n; ++
i)
986 if (!rBaseName.isEmpty() && pDoc->
maTableNames.size() == 1)
988 OUString aSheetName = getFirstSheetName();
1002 const OUString& rTabName )
const
1005 TableNameIndexMap::const_iterator itrTabName = maTableNameIndex.find( aTabNameUpper);
1006 if (itrTabName != maTableNameIndex.end())
1012 if (maSingleTableNameAlias.isEmpty() || maTableNameIndex.size() != 1)
1019 return maTableNameIndex.begin();
1026 if (maSingleTableNameAlias.isEmpty() || maTableNames.size() != 1)
1030 rTabName = maSingleTableNameAlias;
1035 rTabName = maTableNames[0].maRealName;
1042 sal_uInt16 nFileId )
const
1044 bool bFound = rSrcDoc.
GetTable( rTabName, rTab);
1051 OUString aTabName( rTabName);
1053 bFound = rSrcDoc.
GetTable( aTabName, rTab);
1062 if( nCacheId < pDoc->maTableNames.size() )
1063 return pDoc->maTableNames[ nCacheId ].maRealName;
1075 rTabNames.reserve(
n);
1077 rTabNames.push_back(rTableName.maRealName);
1086 vector<TableName>::const_iterator itrBeg = pDoc->
maTableNames.begin();
1087 vector<TableName>::const_iterator itrEnd = pDoc->
maTableNames.end();
1089 vector<TableName>::const_iterator itrStartTab = ::std::find_if( itrBeg, itrEnd,
1090 TabNameSearchPredicate( rStartTabName));
1091 if (itrStartTab == itrEnd)
1094 vector<TableName>::const_iterator itrEndTab = ::std::find_if( itrBeg, itrEnd,
1095 TabNameSearchPredicate( rEndTabName));
1096 if (itrEndTab == itrEnd)
1099 size_t nStartDist = ::std::distance( itrBeg, itrStartTab);
1100 size_t nEndDist = ::std::distance( itrBeg, itrEndTab);
1101 return nStartDist <= nEndDist ? static_cast<SCTAB>(nEndDist - nStartDist + 1) : -
static_cast<SCTAB>(nStartDist - nEndDist + 1);
1109 using ::std::unique;
1111 vector<sal_uInt32> aNumFmts;
1112 for (
const auto& rEntry :
maDocs)
1114 const vector<TableTypeRef>& rTables = rEntry.second.maTables;
1120 pTab->getAllNumberFormats(aNumFmts);
1125 sort(aNumFmts.begin(), aNumFmts.end());
1126 aNumFmts.erase(unique(aNumFmts.begin(), aNumFmts.end()), aNumFmts.end());
1127 rNumFmts.swap(aNumFmts);
1136 for (
auto& rxTab : pDocItem->
maTables)
1139 rxTab->setReferenced(
true);
1153 size_t nStop = ::std::min(
nIndex + nSheets, pDoc->
maTables.size());
1159 if (!pTab->isReferenced())
1161 pTab->setReferenced(
true);
1178 for (
auto& rEntry :
maDocs)
1181 for (
auto& rxTab : rDocItem.
maTables)
1184 rxTab->setReferenced(
true);
1191 auto itrMax = std::max_element(
maDocs.begin(),
maDocs.end(),
1192 [](
const DocDataType::value_type&
a,
const DocDataType::value_type& b) { return a.first < b.first; });
1193 if (itrMax !=
maDocs.end())
1194 nDocs = itrMax->first + 1;
1197 for (
auto& [nFileId, rDocItem] :
maDocs)
1199 size_t nTables = rDocItem.maTables.size();
1202 rDocReferenced.
maTables.resize( nTables,
true);
1203 for (
size_t i=0;
i < nTables; ++
i)
1208 xTab->setReferenced(
false);
1226 size_t nTables = rTables.size();
1234 while (
i < nTables && rTables[
i])
1252 size_t nSize = rTables.size();
1253 for (
size_t i=0;
i < nSize; ++
i)
1267 const std::vector<TableTypeRef>& rTables = pDocItem->
maTables;
1268 for (
size_t nTab = 0, nTabCount = rTables.size(); nTab < nTabCount; ++nTab)
1274 std::vector<SCROW> aRows;
1275 pTab->getAllRows(aRows);
1276 for (
SCROW nRow : aRows)
1278 std::vector<SCCOL> aCols;
1279 pTab->getAllCols(nRow, aCols);
1280 for (
SCCOL nCol : aCols)
1282 rSet.set(rSrcDoc, nTab, nCol, nRow,
true);
1289 mbAllReferenced(false)
1298 mbAllReferenced =
false;
1304 mbAllReferenced =
true;
1313 mbAllReferenced =
true;
1319 if (!pDoc || nTabIndex >= pDoc->
maTables.size())
1326 bool bCreateNew,
size_t* pnIndex,
const OUString* pExtUrl)
1332 const size_t nNotAvailable =
static_cast<size_t>(
static_cast<sal_Int32
>( -1));
1337 if (pnIndex) *pnIndex = nNotAvailable;
1347 if( pnIndex ) *pnIndex =
nIndex;
1356 if (pnIndex) *pnIndex = nNotAvailable;
1367 const OUString aSheetName( getFirstSheetName());
1382 if( pnIndex ) *pnIndex =
nIndex;
1385 rDoc.
maTableNames.emplace_back(aTabNameUpper, rTabName);
1405 std::vector<TableTypeRef>& rTabs = pDocItem->
maTables;
1430 DocDataType::iterator itrDoc =
maDocs.find(nFileId);
1431 if (itrDoc ==
maDocs.end())
1434 pair<DocDataType::iterator, bool> res =
maDocs.emplace(
1444 return &itrDoc->second;
1470 OUString aFile, aFilter;
1481 if (*pCurFile == aFile)
1536 if (nError != FormulaError::NONE)
1550 OSL_FAIL(
"attempted to convert an unknown cell type.");
1574 std::unique_ptr<ScRange> pUsedRange;
1576 unique_ptr<ScTokenArray> pArray(
new ScTokenArray(rSrcDoc));
1577 bool bFirstTab =
true;
1578 vector<ScExternalRefCache::SingleRangeData>::iterator
1579 itrCache = rCacheData.begin(), itrCacheEnd = rCacheData.end();
1581 for (
SCTAB nTab = nTab1; nTab <= nTab2 && itrCache != itrCacheEnd; ++nTab, ++itrCache)
1584 SCCOL nDataCol1 = nCol1, nDataCol2 = nCol2;
1585 SCROW nDataRow1 = nRow1, nDataRow2 = nRow2;
1587 if (!rSrcDoc.
ShrinkToUsedDataArea( bShrunk, nTab, nDataCol1, nDataRow1, nDataCol2, nDataRow2,
false))
1593 pUsedRange->ExtendTo(
ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
1595 pUsedRange.reset(
new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
1597 SCSIZE nMatrixColumns =
static_cast<SCSIZE>(nCol2-nCol1+1);
1598 SCSIZE nMatrixRows =
static_cast<SCSIZE>(nRow2-nRow1+1);
1609 SCSIZE nMatCols, nMatRows;
1610 xMat->GetDimensions( nMatCols, nMatRows);
1611 if (nMatCols == nMatrixColumns && nMatRows == nMatrixRows)
1615 else if ((nCol1 == 0 && nCol2 == rSrcDoc.
MaxCol()) || (nRow1 == 0 && nRow2 == rSrcDoc.
MaxRow()))
1620 nMatrixColumns =
static_cast<SCSIZE>(nDataCol2-nDataCol1+1);
1621 nMatrixRows =
static_cast<SCSIZE>(nDataRow2-nDataRow1+1);
1622 xMat =
new ScMatrix( nMatrixColumns, nMatrixRows);
1623 xMat->GetDimensions( nMatCols, nMatRows);
1624 if (nMatCols == nMatrixColumns && nMatRows == nMatrixRows)
1630 pArray->AddOpCode(
ocSep);
1633 pArray->AddToken(aToken);
1635 itrCache->mpRangeData = xMat;
1643 s.
SetCol(pUsedRange->aStart.Col());
1644 s.
SetRow(pUsedRange->aStart.Row());
1645 e.
SetCol(pUsedRange->aEnd.Col());
1646 e.
SetRow(pUsedRange->aEnd.Row());
1658 unique_ptr<ScTokenArray> pArray(
new ScTokenArray(rDoc));
1659 pArray->AddToken(aToken);
1664bool isLinkUpdateAllowedInDoc(
const ScDocument& rDoc)
1677 mbInReferenceMarking(false),
1678 mbUserInteractionEnabled(true),
1679 mbDocTimerEnabled(true),
1680 maSrcDocTimer(
"sc::ScExternalRefManager maSrcDocTimer" )
1702 sal_uInt16 nFileId,
const OUString& rTabName,
bool bCreateNew,
size_t* pnIndex,
const OUString* pExtUrl)
1716 mpMgr(rDoc.GetExternalRefManager()),
1726 mpMgr->mbUserInteractionEnabled = mbOldInteractionEnabled;
1746 return static_cast< sal_uInt16
>(
maSrcFiles.size() );
1751 bool bAllMarked =
false;
1754 if (!rLinkListeners.empty())
1797 pNewArray = std::make_shared<ScTokenArray>(
mrDoc);
1801 bool bTokenAdded =
false;
1802 switch (pToken->GetType())
1808 if (
SCTAB nCacheId = rRef.
Tab(); nCacheId >= 0)
1811 *pToken->GetSingleRef());
1812 pNewArray->AddToken(aNewToken);
1820 if (
SCTAB nCacheId = rRef.
Tab(); nCacheId >= 0)
1823 *pToken->GetDoubleRef());
1824 pNewArray->AddToken(aNewToken);
1833 pNewArray->AddToken(*pToken);
1837 pNewArray = rArray.
Clone();
1850void putCellDataIntoCache(
1852 sal_uInt16 nFileId,
const OUString& rTabName,
const ScAddress& rCell,
1859 rRefCache.
setCellData(nFileId, rTabName, rCell.
Col(), rCell.
Row(), pToken, nFmtIndex);
1876void putRangeDataIntoCache(
1878 sal_uInt16 nFileId,
const OUString& rTabName,
1879 const vector<ScExternalRefCache::SingleRangeData>& rCacheData,
1893 rRefCache.
getCacheTable(nFileId, rTabName,
true,
nullptr,
nullptr);
1895 pCacheTab->setCachedCellRange(
1924 vector<OUString> aTabNames;
1925 aTabNames.reserve(nTabCount);
1926 for (
SCTAB i = 0;
i < nTabCount; ++
i)
1930 aTabNames.push_back(aName);
1951 sal_uInt16 nFileId )
const
1957 sal_uInt16 nFileId,
const OUString& rTabName,
const ScAddress& rCell,
1990 putCellDataIntoCache(
maRefCache, pToken, nFileId, rTabName, rCell, pFmt);
1995 sal_uInt32 nFmtIndex = 0;
1997 nFileId, rTabName, rCell.
Col(), rCell.
Row(), &nFmtIndex);
2010 if (!isLinkUpdateAllowedInDoc(
mrDoc))
2034 SCCOL nDataCol1 = 0, nDataCol2 = pSrcDoc->
MaxCol();
2035 SCROW nDataRow1 = 0, nDataRow2 = pSrcDoc->
MaxRow();
2036 bool bData = pSrcDoc->
ShrinkToDataArea(nTab, nDataCol1, nDataRow1, nDataCol2, nDataRow2);
2037 if (!bData || rCell.
Col() < nDataCol1 || nDataCol2 < rCell.
Col() || rCell.
Row() < nDataRow1 || nDataRow2 < rCell.
Row())
2045 pCacheTab->setCachedCell(rCell.
Col(), rCell.
Row());
2054 putCellDataIntoCache(
maRefCache, pToken, nFileId, rTabName, rCell, pFmt);
2059 sal_uInt16 nFileId,
const OUString& rTabName,
const ScRange& rRange,
const ScAddress* pCurPos)
2071 vector<ScExternalRefCache::SingleRangeData> aCacheData;
2076 putRangeDataIntoCache(
maRefCache, pArray, nFileId, rTabName, aCacheData, rRange, aDataRange);
2096 vector<ScExternalRefCache::SingleRangeData> aCacheData;
2100 putRangeDataIntoCache(
maRefCache, pArray, nFileId, rTabName, aCacheData, rRange, aDataRange);
2105 sal_uInt16 nFileId,
const OUString& rName,
const ScAddress* pCurPos)
2112 OUString
aName = rName;
2148bool hasRangeName(
const ScDocument& rDoc,
const OUString& rName)
2153 return pRangeData !=
nullptr;
2165 if (hasRangeName(*pSrcDoc, rName))
2182 if (hasRangeName(*pSrcDoc, rName))
2193 RefCellMap::iterator itrFile =
maRefCells.find(nFileId);
2198 for_each(rRefCells.begin(), rRefCells.end(), UpdateFormulaCell());
2216void insertRefCellByIterator(
2217 const ScExternalRefManager::RefCellMap::iterator& itr,
ScFormulaCell* pCell)
2221 itr->second.insert(pCell);
2230 RefCellMap::iterator itr =
maRefCells.find(nFileId);
2234 pair<RefCellMap::iterator, bool> r =
maRefCells.emplace(
2235 nFileId, aRefCells);
2248 if (!pTemplateCell || !pCell)
2253 if (itr->second.find(pTemplateCell) != itr->second.end())
2254 insertRefCellByIterator(itr, pCell);
2264 [&pCell](
const RefCellMap::value_type& rEntry) { return rEntry.second.find(pCell) != rEntry.second.end(); });
2295 if (nFmtType != SvNumFormatType::UNDEFINED)
2326 vector<ScExternalRefCache::SingleRangeData>& rCacheData)
2331 if (!rSrcDoc.
GetTable(rTabName, nTab1))
2334 pArray = std::make_shared<ScTokenArray>(rSrcDoc);
2343 vector<ScExternalRefCache::SingleRangeData> aCacheData;
2344 aCacheData.reserve(nTabSpan+1);
2345 aCacheData.emplace_back();
2348 for (
SCTAB i = 1;
i < nTabSpan + 1; ++
i)
2351 if (!rSrcDoc.
GetName(nTab1 + 1, aTabName))
2355 aCacheData.emplace_back();
2364 rCacheData.swap(aCacheData);
2369 sal_uInt16 nFileId,
const ScDocument& rSrcDoc, OUString& rName)
2388 bool bTokenAdded =
false;
2389 switch (pToken->GetType())
2397 *pToken->GetSingleRef());
2398 pNew->AddToken(aNewToken);
2408 *pToken->GetDoubleRef());
2409 pNew->AddToken(aNewToken);
2418 pNew->AddToken(*pToken);
2421 rName = pRangeData->
GetName();
2432 if (!isLinkUpdateAllowedInDoc(
mrDoc))
2440 if (pMedium && !pMedium->
GetName().isEmpty())
2443 if (pFileName->equalsIgnoreAsciiCase(pMedium->
GetName()))
2454 if (pFileName->equalsIgnoreAsciiCase(
aName))
2468 initDocInCache(
maRefCache, pSrcDoc, nFileId);
2478 DocShellMap::iterator itr =
maDocShells.find(nFileId);
2486 return &
static_cast<ScDocShell*
>(
p)->GetDocument();
2497 return &
static_cast<ScDocShell*
>(
p)->GetDocument();
2511 catch (
const css::uno::Exception&)
2526 if (!isLinkUpdateAllowedInDoc(
mrDoc))
2550 std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName(rFilter);
2565 if (!aOptions.isEmpty())
2586 pItem->
GetValue() != css::document::MacroExecMode::NEVER_EXECUTE)
2587 pSet->Put(
SfxUInt16Item( SID_MACROEXECMODE, css::document::MacroExecMode::USE_CONFIG));
2590 pSet->Put(
SfxUInt16Item( SID_UPDATEDOCMODE, css::document::UpdateDocMode::FULL_UPDATE));
2593 unique_ptr<SfxMedium> pMedium(
new SfxMedium(aFile, StreamMode::STD_READ, pFilter, std::move(pSet)));
2620 if (!pNewShell->
DoLoad(pMedium.release()))
2629 if (!aNew.isEmpty() && aNew != aOptions)
2645 initDocInCache(
maRefCache, &rSrcDoc, nFileId);
2651 if (rFile.isEmpty())
2657 if (osl::FileBase::getSystemPathFromFileURL(rFile, aPhysical)
2658 == osl::FileBase::E_None)
2682 OUString aFilter, aOptions;
2691 if (!bDeferFilterDetection)
2692 bDeferFilterDetection = !isLinkUpdateAllowedInDoc(
mrDoc);
2698 if (aFilter.isEmpty() && !bDeferFilterDetection)
2703 SAL_WARN(
"sc.ui",
"ScExternalRefManager::maybeLinkExternalFile: pLinkMgr==NULL");
2707 OSL_ENSURE(pFileName,
"ScExternalRefManager::maybeLinkExternalFile: file name pointer is NULL");
2709 (aFilter.isEmpty() && bDeferFilterDetection ?
nullptr : &aFilter));
2711 pLink->SetDoRefresh(
false);
2713 pLink->SetDoRefresh(
true);
2724 "sc.ui",
"ScExternalRefManager::addFilesToLinkManager: files overflow");
2726 for (sal_uInt16 nFileId = 0; nFileId < nSize; ++nFileId)
2732 if (maRelativeName.isEmpty())
2736 if (!maRealFileName.isEmpty())
2741 const OUString& rRelPath = maRelativeName;
2744 bool bWasAbs =
false;
2759 return "file:///tmp/document";
2784 if (rFile == pShell->
GetName())
2797 vector<SrcFileData>::const_iterator itr = find_if(itrBeg, itrEnd, FindSrcFileByName(rFile));
2801 return static_cast<sal_uInt16
>(
nId);
2805 aData.maFileName = rFile;
2807 return static_cast<sal_uInt16
>(
maSrcFiles.size() - 1);
2820 if (!
maSrcFiles[nFileId].maRealFileName.isEmpty())
2840 for (
auto nEntry : rExternFileIds)
2853 std::vector<OUString> aNames;
2857 aNames.push_back(rData.maFileName);
2891template<
typename MapContainer>
2894 typename MapContainer::iterator itr = rMap.find(nFileId);
2895 if (itr != rMap.end())
2898 itr->second.maShell->DoClose();
2916 sal_uInt16 mnFileId;
2922 mrStrPool(rStrPool), mrRefCache(rRefCache), mnFileId(nFileId), mpCurCol(nullptr) {}
2924 virtual void startColumn(
ScColumn* pCol )
override
2934 virtual void execute(
SCROW nRow1,
SCROW nRow2,
bool bVal )
override
2936 if (!mpCurCol || !bVal)
2942 for (
SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
2989 mpRefTab->setCachedCell(mpCurCol->
GetCol(), nRow);
3005 catch (
const css::uno::Exception& ) {}
3007 if (!xDocShell.
is())
3023 DocShellMap::iterator it =
maDocShells.find(nFileId);
3026 it->second.maShell->DoClose();
3027 it->second.maShell = xDocShell;
3050 RefCellMap::iterator itrRefs =
maRefCells.find(nFileId);
3056 for_each(aSet.begin(), aSet.end(), ConvertFormulaToStatic(&
mrDoc));
3065 removeRangeNamesBySrcDoc(*pRanges, nFileId);
3072 removeRangeNamesBySrcDoc(*pRanges, nFileId);
3081 LinkedDocMap::iterator itr =
maLinkedDocs.find(nFileId);
3083 itr->second =
false;
3093 if (
maSrcFiles[nFileId].maFilterName != rNewFilter)
3096 maSrcFiles[nFileId].maFilterName = rNewFilter;
3106 maSrcFiles[nFileId].maRelativeName = rRelUrl;
3113 maSrcFiles[nFileId].maFilterName = rFilterName;
3114 maSrcFiles[nFileId].maFilterOptions = rOptions;
3121 for (
auto& it : rEntry.second)
3128 rEntry.second.maShell->DoClose();
3144 OUString aAbsName = rSrcFile.maRealFileName;
3145 if (aAbsName.isEmpty())
3146 aAbsName = rSrcFile.maFileName;
3149 rBaseFileUrl, aAbsName);
3161 rSrcFile.maybeCreateRealFileName( aOwn );
3162 OUString aReal = rSrcFile.maRealFileName;
3163 if (!aReal.isEmpty())
3164 rSrcFile.maFileName = aReal;
3182 OSL_FAIL(
"insertion of new link listener list failed");
3201 rList.
erase(pListener);
3211 rEntry.second.erase(pListener);
3222 for_each(rList.
begin(), rList.
end(), NotifyLinkListener(nFileId,
eType));
3229 [nTimeOut](
const DocShellMap::value_type& rEntry) {
3231 sal_Int32 nSinceLastAccess = (tools::Time( tools::Time::SYSTEM ) - rEntry.second.maLastAccess).GetTime();
3232 return nSinceLastAccess >= nTimeOut;
3237 itr->second.maShell->DoClose();
3261 itr->second.swap(
aMap);
3264 SvNumberFormatterMergeMap::const_iterator itrNumFmt = rMap.find(nNumFmt);
3265 if (itrNumFmt != rMap.end())
3267 return itrNumFmt->second;
3277 if ( itr->second.maShell.get() == pShell )
3299 case SfxEventHintId::PrepareCloseDoc:
3302 VclMessageType::Warning, VclButtonsType::Ok,
3303 ScResId(STR_CLOSE_WITH_UNSAVED_REFS)));
3307 case SfxEventHintId::SaveDocDone:
3308 case SfxEventHintId::SaveAsDocDone:
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
SfxApplication * SfxGetpApp()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
sal_uInt16 GetValue() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetURLObject smartRel2Abs(OUString const &rTheRelURIRef, bool &rWasAbsolute, bool bIgnoreFragment=false, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, bool bRelativeNonURIs=false, FSysStyle eStyle=FSysStyle::Detect) const
bool insertName(std::u16string_view rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
void InitBlockPosition(sc::ColumnBlockPosition &rBlockPos)
ScRefCellValue GetCellValue(SCROW nRow) const
ScDocument & GetDoc() const
sal_uInt32 GetNumberFormat(const ScInterpreterContext &rContext, SCROW nRow) const
const OUString & GetInitTabPrefix() const
Create before modifications of the document and destroy thereafter.
void SetDocumentModified()
static weld::Window * GetActiveDialogParent()
const ScDocument & GetDocument() const
static ScViewData * GetViewData()
static OUString GetOptions(const SfxMedium &rMedium)
static bool GetFilterName(const OUString &rFileName, OUString &rFilter, OUString &rOptions, bool bWithContent, bool bWithInteraction)
Returns the filter name and options from a file name.
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC void EnableUserInteraction(bool bVal)
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
bool ShrinkToDataArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow) const
Shrink a range to only include data area.
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC void EnableUndo(bool bVal)
ScInterpreterContext & GetNonThreadedContext() const
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
Shrink a range to only include used data area.
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
void EnableExecuteLink(bool bVal)
ScExtDocOptions * GetExtDocOptions()
bool IsFunctionAccess() const
bool IsExecuteLinkEnabled() const
SfxObjectShell * GetDocumentShell() const
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
SC_DLLPUBLIC void SetExtDocOptions(std::unique_ptr< ScExtDocOptions > pNewOptions)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
SC_DLLPUBLIC const ScFormulaCell * GetFormulaCell(const ScAddress &rPos) const
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
void FillMatrix(ScMatrix &rMat, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool *pPool=nullptr) const
SC_DLLPUBLIC SCTAB GetTableCount() const
Extended options held by an ScDocument containing additional settings for filters.
const ScExtDocSettings & GetDocSettings() const
void getAllRows(::std::vector< SCROW > &rRows, SCROW nLow, SCROW nHigh) const
Obtain a sorted vector of rows.
bool hasRow(SCROW nRow) const
SC_DLLPUBLIC TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32 *pnFmtIndex=nullptr) const
void getAllNumberFormats(::std::vector< sal_uInt32 > &rNumFmts) const
bool isRangeCached(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
void setReferenced(bool bReferenced)
Set/clear referenced status flag only if current status is not REFERENCED_PERMANENT.
SC_DLLPUBLIC void setWholeTableCached()
Call this to mark the entire table "cached".
bool isReferenced() const
SC_DLLPUBLIC void setCell(SCCOL nCol, SCROW nRow, TokenRef const &pToken, sal_uLong nFmtIndex=0, bool bSetCacheRange=true)
Add cell value to the cache.
bool isInCachedRanges(SCCOL nCol, SCROW nRow) const
TokenRef getEmptyOrNullToken(SCCOL nCol, SCROW nRow) const
void setCachedCellRange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void setCachedCell(SCCOL nCol, SCROW nRow)
SC_DLLPUBLIC ::std::pair< SCROW, SCROW > getRowRange() const
Returns the half-open range of used rows in this table. Returns [0,0) if table is empty.
SC_DLLPUBLIC ::std::pair< SCCOL, SCCOL > getColRange(SCROW nRow) const
Returns the half-open range of used columns in the specified row. Returns [0,0) if row is empty.
void getAllCols(SCROW nRow, ::std::vector< SCCOL > &rCols, SCCOL nLow, SCCOL nHigh) const
Obtain a sorted vector of columns.
Cache table for external reference data.
bool setCacheDocReferenced(sal_uInt16 nFileId)
Set all tables of a document as referenced, used only during store-to-file.
bool isValidRangeName(sal_uInt16 nFileId, const OUString &rName) const
bool isDocInitialized(sal_uInt16 nFileId)
void clearCache(sal_uInt16 nFileId)
Clear all caches including the cache tables.
std::unordered_map< OUString, TokenArrayRef > RangeNameMap
std::shared_ptr< Table > TableTypeRef
void getAllTableNames(sal_uInt16 nFileId, ::std::vector< OUString > &rTabNames) const
ScExternalRefCache::TokenArrayRef getCellRangeData(sal_uInt16 nFileId, const OUString &rTabName, const ScRange &rRange)
Get a cached cell range data.
std::unordered_map< OUString, size_t > TableNameIndexMap
DocItem * getDocItem(sal_uInt16 nFileId) const
ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const OUString &rName)
void setRangeNameTokens(sal_uInt16 nFileId, const OUString &rName, TokenArrayRef pArray)
void getAllNumberFormats(::std::vector< sal_uInt32 > &rNumFmts) const
struct ScExternalRefCache::ReferencedStatus maReferenced
void setAllCacheTableReferencedStati(bool bReferenced)
void setRangeName(sal_uInt16 nFileId, const OUString &rName)
void getAllCachedDataSpans(const ScDocument &rSrcDoc, sal_uInt16 nFileId, sc::ColumnSpanSet &rSet) const
Collect all cached non-empty cell positions, inferred directly from the cached data,...
bool setCacheTableReferenced(sal_uInt16 nFileId, const OUString &rTabName, size_t nSheets)
Set a table as referenced, used only during store-to-file.
const ScDocument & getDoc() const
void setCellRangeData(sal_uInt16 nFileId, const ScRange &rRange, const ::std::vector< SingleRangeData > &rData, const TokenArrayRef &pArray)
SCTAB getTabSpan(sal_uInt16 nFileId, const OUString &rStartTabName, const OUString &rEndTabName) const
void clearCacheTables(sal_uInt16 nFileId)
Clear all caches but keep the tables.
std::unordered_map< SCCOL, Cell > RowDataType
void addCacheDocToReferenced(sal_uInt16 nFileId)
ScExternalRefCache(const ScDocument &rDoc)
void initializeDoc(sal_uInt16 nFileId, const ::std::vector< OUString > &rTabNames, const OUString &rBaseName)
void addCacheTableToReferenced(sal_uInt16 nFileId, size_t nIndex)
::formula::FormulaTokenRef TokenRef
OUString getTableName(sal_uInt16 nFileId, size_t nCacheId) const
const OUString * getRealRangeName(sal_uInt16 nFileId, const OUString &rRangeName) const
bool getSrcDocTable(const ScDocument &rSrcDoc, const OUString &rTabName, SCTAB &rTab, sal_uInt16 nFileId) const
ScExternalRefCache::TokenRef getCellData(sal_uInt16 nFileId, const OUString &rTabName, SCCOL nCol, SCROW nRow, sal_uInt32 *pnFmtIndex)
Get a cached cell data at specified cell location.
bool areAllCacheTablesReferenced() const
const OUString * getRealTableName(sal_uInt16 nFileId, const OUString &rTabName) const
std::shared_ptr< ScTokenArray > TokenArrayRef
void setCellData(sal_uInt16 nFileId, const OUString &rTabName, SCCOL nCol, SCROW nRow, TokenRef const &pToken, sal_uLong nFmtIndex)
ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const
void SetDoRefresh(bool b)
virtual void Closed() override
virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(const OUString &rMimeType, const css::uno::Any &rValue) override
virtual ~ScExternalRefLink() override
virtual void Edit(weld::Window *pParent, const Link< SvBaseLink &, void > &rEndEditHdl) override
ScExternalRefLink()=delete
ScExternalRefManager * mpMgr
ApiGuard(const ScDocument &rDoc)
Base class for objects that need to listen to link updates.
virtual ~LinkListener() COVERITY_NOEXCEPT_FALSE=0
sal_uInt16 getExternalFileCount() const
sal_uInt32 getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, const ScDocument &rSrcDoc)
SCTAB getCachedTabSpan(sal_uInt16 nFileId, const OUString &rStartTabName, const OUString &rEndTabName) const
Get the span (distance+sign(distance)) of two sheets of a specified file.
void setFilterData(sal_uInt16 nFileId, const OUString &rFilterName, const OUString &rOptions)
Set the filter name and options if any for a given source document.
bool isFileLoadable(const OUString &rFile) const
Check if the file specified by the path is a legitimate file that exists & can be loaded.
DocShellMap maUnsavedDocShells
DocShells to unsaved but referenced documents.
DocShellMap maDocShells
Source document cache.
ScExternalRefCache maRefCache
cache of referenced ranges and names from source documents.
void insertRefCellFromTemplate(ScFormulaCell *pTemplateCell, ScFormulaCell *pCell)
Add a cell to reference the same files as the template cell.
void enableDocTimer(bool bEnable)
SfxObjectShellRef loadSrcDocument(sal_uInt16 nFileId, OUString &rFilter)
bool getSrcDocTable(const ScDocument &rSrcDoc, const OUString &rTabName, SCTAB &rTab, sal_uInt16 nFileId) const
ScExternalRefCache::TokenArrayRef getDoubleRefTokensFromSrcDoc(const ScDocument &rSrcDoc, const OUString &rTabName, ScRange &rRange, ::std::vector< ScExternalRefCache::SingleRangeData > &rCacheData)
Retrieve a range token array from a source document instance.
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
LinkListenerMap maLinkListeners
sal_uInt16 getExternalFileId(const OUString &rFile)
const OUString * getRealTableName(sal_uInt16 nFileId, const OUString &rTabName) const
LinkedDocMap maLinkedDocs
list of source documents that are managed by the link manager.
void markUsedExternalRefCells()
void maybeLinkExternalFile(sal_uInt16 nFileId, bool bDeferFilterDetection=false)
void resetSrcFileData(const OUString &rBaseFileUrl)
Re-generates relative names for all stored source files.
std::vector< sal_uInt16 > maConvertFileIdToUsedFileId
void getAllCachedNumberFormats(::std::vector< sal_uInt32 > &rNumFmts) const
Get all unique number format indices that are used in the cache tables.
ScExternalRefManager(ScDocument &rDoc)
void removeRefCell(ScFormulaCell *pCell)
Stop tracking a specific formula cell.
ScDocument & cacheNewDocShell(sal_uInt16 nFileId, SrcShell &rSrcShell)
Caller must ensure that the passed shell is not already stored.
void setAllCacheTableReferencedStati(bool bReferenced)
std::set< ScFormulaCell * > RefCellSet
virtual ~ScExternalRefManager() override
void addLinkListener(sal_uInt16 nFileId, LinkListener *pListener)
Register a new link listener to a specified external document.
virtual OUString getCacheTableName(sal_uInt16 nFileId, size_t nTabIndex) const override
void maybeCreateRealFileName(sal_uInt16 nFileId)
Try to create a "real" file name from the relative path.
bool setCacheTableReferenced(sal_uInt16 nFileId, const OUString &rTabName, size_t nSheets)
Set a table as referenced, used only during store-to-file.
bool hasExternalFile(sal_uInt16 nFileId) const
ScDocument * getSrcDocument(sal_uInt16 nFileId)
o3tl::sorted_vector< LinkListener * > LinkListeners
bool isValidRangeName(sal_uInt16 nFileId, const OUString &rName)
void setSkipUnusedFileIds(std::vector< sal_uInt16 > &pExternFileIds)
sal_uInt16 convertFileIdToUsedFileId(sal_uInt16 nFileId)
Reindex external file references to skip unused files, if skipping is enabled.
void switchSrcFile(sal_uInt16 nFileId, const OUString &rNewFile, const OUString &rNewFilter)
ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const
Get a cache table instance for specified table and table index.
void refreshAllRefCells(sal_uInt16 nFileId)
const SrcFileData * getExternalFileData(sal_uInt16 nFileId) const
void disableSkipUnusedFileIds()
void removeLinkListener(sal_uInt16 nFileId, LinkListener *pListener)
Remove an existing link listener.
void updateAbsAfterLoad()
Replace the original URL with the real URL that was generated from the relative URL.
bool mbInReferenceMarking
Status whether in reference marking state.
RefCellMap maRefCells
List of referencing cells that may contain external names.
void markUsedByLinkListeners()
Mark all tables as referenced that are used by any LinkListener, used only during store-to-file.
const OUString * getRealRangeName(sal_uInt16 nFileId, const OUString &rRangeName) const
void addFilesToLinkManager()
Add all known external files to the LinkManager.
OUString getOwnDocumentName() const
bool hasCellExternalReference(const ScAddress &rCell)
const OUString * getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal=false)
It returns a pointer to the name of the URI associated with a given external file ID.
ScExternalRefCache::TokenRef getSingleRefTokenFromSrcDoc(sal_uInt16 nFileId, ScDocument &rSrcDoc, const ScAddress &rPos, ScExternalRefCache::CellFormat *pFmt)
ScExternalRefCache::TokenArrayRef getDoubleRefTokens(sal_uInt16 nFileId, const OUString &rTabName, const ScRange &rRange, const ScAddress *pCurPos)
Get an array of tokens that consist of the specified external cell range.
void transformUnsavedRefToSavedRef(SfxObjectShell *pShell)
If in maUnsavedDocShells move it to maDocShells and create a correct external reference entry.
void convertToAbsName(OUString &rFile) const
Takes a flat file name, and convert it to an absolute URL path.
void insertRefCell(sal_uInt16 nFileId, const ScAddress &rCell)
void getAllCachedTableNames(sal_uInt16 nFileId, ::std::vector< OUString > &rTabNames) const
Returns a vector containing all (real) table names and cache tables of the specified file.
bool hasExternalData() const
void notifyAllLinkListeners(sal_uInt16 nFileId, LinkUpdateType eType)
Notify all listeners that are listening to a specified external document.
bool mbUserInteractionEnabled
Controls whether or not to allow user interaction.
std::vector< SrcFileData > maSrcFiles
List of external source document meta-data, used to keep track of external document identifiers.
void clearCache(sal_uInt16 nFileId)
void setRelativeFileName(sal_uInt16 nFileId, const OUString &rRelUrl)
Set a relative file path for the specified file ID.
std::vector< OUString > getAllCachedExternalFileNames() const
Get all cached external file names as an array.
bool isOwnDocument(std::u16string_view rFile) const
void fillCellFormat(sal_uLong nFmtIndex, ScExternalRefCache::CellFormat *pFmt) const
ScDocument * getInMemorySrcDocument(sal_uInt16 nFileId)
void storeRangeNameTokens(sal_uInt16 nFileId, const OUString &rName, const ScTokenArray &rArray)
@ OH_NO_WE_ARE_GOING_TO_DIE
ScExternalRefCache::TokenRef getSingleRefToken(sal_uInt16 nFileId, const OUString &rTabName, const ScAddress &rCell, const ScAddress *pCurPos, SCTAB *pTab, ScExternalRefCache::CellFormat *pFmt=nullptr)
void purgeStaleSrcDocument(sal_Int32 nTimeOut)
Purge those source document instances that have not been accessed for the specified duration.
ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const OUString &rName, const ScAddress *pCurPos=nullptr)
Get an array of tokens corresponding with a specified name in a specified file.
void breakLink(sal_uInt16 nFileId)
static ScExternalRefCache::TokenArrayRef getRangeNameTokensFromSrcDoc(sal_uInt16 nFileId, const ScDocument &rSrcDoc, OUString &rName)
Retrieve range name token array from a source document instance.
bool refreshSrcDocument(sal_uInt16 nFileId)
static SC_DLLPUBLIC ::utl::TransliterationWrapper & GetTransliteration()
static SC_DLLPUBLIC OUString GetAbsDocName(const OUString &rFileName, const SfxObjectShell *pShell)
static SC_DLLPUBLIC const CharClass & getCharClass()
Matrix data type that can store values of mixed types.
std::function< void(size_t, size_t)> EmptyOpFunction
std::function< void(size_t, size_t, svl::SharedString)> StringOpFunction
std::function< void(size_t, size_t, double)> DoubleOpFunction
std::function< void(size_t, size_t, bool)> BoolOpFunction
void GetName(OUString &rName) const
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
void erase(const ScRangeData &r)
SC_DLLPUBLIC const_iterator end() const
DataType::const_iterator const_iterator
SC_DLLPUBLIC const_iterator begin() const
std::unique_ptr< ScTokenArray > Clone() const
ScDocShell * GetDocShell() const
ScTabViewShell * GetViewShell() const
SfxEventHintId GetEventId() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
const INetURLObject & GetURLObject() const
SfxItemSet & GetItemSet() const
const OUString & GetName() const
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SfxMedium * GetMedium() const
bool DoLoad(SfxMedium *pMedium)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
const OUString & GetName() const
virtual void Invalidate(sal_uInt16 nId=0)
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual void Start(bool bStartTimer=true) override
bool getUserAllowsLinkUpdate() const
const_iterator begin() const
size_type erase(const Value &x)
const_iterator end() const
std::pair< const_iterator, bool > insert(Value &&x)
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
void executeColumnAction(ScDocument &rDoc, ColumnAction &ac) const
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, std::u16string_view rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
SharedString intern(const OUString &rStr)
const OUString & getString() const
FormulaError GetDoubleErrorValue(double fVal)
static std::unique_ptr< ScTokenArray > convertToTokenArray(ScDocument &rHostDoc, const ScDocument &rSrcDoc, ScRange &rRange, vector< ScExternalRefCache::SingleRangeData > &rCacheData)
static FormulaToken * convertToToken(ScDocument &rHostDoc, const ScDocument &rSrcDoc, ScRefCellValue &rCell)
#define SRCDOC_SCAN_INTERVAL
static std::unique_ptr< ScTokenArray > lcl_fillEmptyMatrix(const ScDocument &rDoc, const ScRange &rRange)
static void lcl_removeByFileId(sal_uInt16 nFileId, MapContainer &rMap)
static bool lcl_getStrictTableDataIndex(const ScExternalRefCache::TableNameIndexMap &rMap, const OUString &rName, size_t &rIndex)
IMPL_LINK(ScExternalRefManager, TimeOutHdl, Timer *, pTimer, void)
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
RttiCompleteObjectLocator col
constexpr OUStringLiteral aData
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
UNOTOOLS_DLLPUBLIC bool Exists(OUString const &url)
UNOTOOLS_DLLPUBLIC bool IsFolder(OUString const &url)
HashMap_OWString_Interface aMap
OUString ScResId(TranslateId aId)
sal_uInt32 mnLinkCnt
Recursive counter for loading external documents.
individual cell within cached external ref table.
Represents data cached for a single external document.
TableNameIndexMap::const_iterator findTableNameIndex(const OUString &rTabName) const
bool getTableDataIndex(const OUString &rTabName, size_t &rIndex) const
::std::vector< TableTypeRef > maTables
The raw cache tables.
TableNameIndexMap maTableNameIndex
Table name to index map.
RangeNameMap maRangeNames
Range name cache.
::std::vector< TableName > maTableNames
Table name list in correct order, in both upper- and real-case.
NamePairMap maRealRangeNameMap
Upper- to real-case mapping for range names.
OUString maSingleTableNameAlias
Either the base name that was stored as sheet name for CSV files if sheet name is Sheet1,...
bool getSingleTableNameAlternative(OUString &rTabName) const
RangeArrayMap maRangeArrays
Token array cache for cell ranges.
bool mbAllTablesReferenced
::std::vector< bool > maTables
::std::vector< DocReferenced > DocReferencedVec
TableName(OUString aUpper, OUString aReal)
Source document meta-data container.
void maybeCreateRealFileName(std::u16string_view rOwnDocName)
OUString maRealFileName
original file name as loaded from the file.
OUString maRelativeName
file name created from the relative name.
Shell instance for a source document.
SfxObjectShellRef maShell
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
OUString getString(const ScDocument *pDoc) const
Retrieve string value.
Store parameters used in the ScDocument::SetString() method.
void setTextInput()
Call this whenever you need to unconditionally set input as text, no matter what the input is.
Single reference (one address) into the sheet.
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
std::unordered_map< sal_uInt32, sal_uInt32 > SvNumberFormatterMergeMap