LibreOffice Module sc (master)  1
externalrefmgr.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #include "address.hxx"
23 #include "document.hxx"
24 #include <sfx2/objsh.hxx>
25 #include <sfx2/lnkbase.hxx>
26 #include <tools/time.hxx>
27 #include <vcl/timer.hxx>
28 #include <svl/zforlist.hxx>
29 #include <svl/lstner.hxx>
30 #include "types.hxx"
31 #include "rangelst.hxx"
32 #include <osl/mutex.hxx>
33 #include <formula/types.hxx>
34 #include <tools/solar.h>
35 
36 #include <memory>
37 #include <unordered_map>
38 #include <unordered_set>
39 #include <vector>
40 #include <set>
41 #include <o3tl/sorted_vector.hxx>
43 
44 class ScTokenArray;
45 namespace weld { class Window; }
46 
47 class ScFormulaCell;
48 
49 namespace sc {
50 
51 class ColumnSpanSet;
52 
53 }
54 
56 {
57 public:
58  ScExternalRefLink(ScDocument& rDoc, sal_uInt16 nFileId);
59  virtual ~ScExternalRefLink() override;
60 
61  virtual void Closed() override;
62  virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
63  const OUString& rMimeType, const css::uno::Any & rValue) override;
64  virtual void Edit(weld::Window* pParent, const Link<SvBaseLink&,void>& rEndEditHdl) override;
65 
66  void SetDoRefresh(bool b);
67 
68 private:
69  ScExternalRefLink() = delete;
70  ScExternalRefLink(const ScExternalRefLink&) = delete;
71 
72  sal_uInt16 mnFileId;
75 };
76 
81 {
82 public:
83  typedef ::formula::FormulaTokenRef TokenRef;
84  typedef std::shared_ptr<ScTokenArray> TokenArrayRef;
85 
86  struct TableName
87  {
88  OUString maUpperName;
89  OUString maRealName;
90 
91  explicit TableName(const OUString& rUpper, const OUString& rReal);
92  };
93 
94  struct CellFormat
95  {
96  bool mbIsSet;
99 
100  explicit CellFormat();
101  };
102 
103 private:
105  struct Cell
106  {
107  TokenRef mxToken;
109  };
110  typedef std::unordered_map<SCCOL, Cell> RowDataType;
111  typedef std::unordered_map<SCROW, RowDataType> RowsDataType;
112 
113 public:
123  class Table
124  {
125  public:
126 
127  Table();
128  ~Table();
129 
130  void clear();
131 
139  SC_DLLPUBLIC void setCell(SCCOL nCol, SCROW nRow, TokenRef const & pToken, sal_uLong nFmtIndex = 0, bool bSetCacheRange = true);
140  SC_DLLPUBLIC TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex = nullptr) const;
141  bool hasRow( SCROW nRow ) const;
144  void setReferenced( bool bReferenced );
145  bool isReferenced() const;
147  void getAllRows(::std::vector<SCROW>& rRows, SCROW nLow, SCROW nHigh) const;
148  void getAllRows(::std::vector<SCROW>& rRows) const;
150  SC_DLLPUBLIC ::std::pair< SCROW, SCROW > getRowRange() const;
152  void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols, SCCOL nLow, SCCOL nHigh) const;
153  void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols) const;
155  SC_DLLPUBLIC ::std::pair< SCCOL, SCCOL > getColRange( SCROW nRow ) const;
156  void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
157  bool isRangeCached(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
158 
159  void setCachedCell(SCCOL nCol, SCROW nRow);
160  void setCachedCellRange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
161 
170  private:
171  bool isInCachedRanges(SCCOL nCol, SCROW nRow) const;
172  TokenRef getEmptyOrNullToken(SCCOL nCol, SCROW nRow) const;
173  template< typename P >
174  void getAllRows(::std::vector<SCROW>& rRows, P predicate) const;
175  template< typename P >
176  void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols, P predicate) const;
177 
178  private:
180  RowsDataType maRows;
185  };
186 
187  typedef std::shared_ptr<Table> TableTypeRef;
188  typedef std::unordered_map< OUString, size_t>
190 
191  ScExternalRefCache(const ScDocument& rDoc);
193 
194  const OUString* getRealTableName(sal_uInt16 nFileId, const OUString& rTabName) const;
195  const OUString* getRealRangeName(sal_uInt16 nFileId, const OUString& rRangeName) const;
196 
208  sal_uInt16 nFileId, const OUString& rTabName, SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex);
209 
218  sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange);
219 
220  ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const OUString& rName);
221  void setRangeNameTokens(sal_uInt16 nFileId, const OUString& rName, TokenArrayRef pArray);
222  bool isValidRangeName(sal_uInt16 nFileId, const OUString& rName) const;
223  void setRangeName(sal_uInt16 nFileId, const OUString& rName);
224 
225  void setCellData(sal_uInt16 nFileId, const OUString& rTabName,
226  SCCOL nCol, SCROW nRow, TokenRef const & pToken, sal_uLong nFmtIndex);
227 
229  {
231  OUString maTableName;
233  };
234  void setCellRangeData(sal_uInt16 nFileId, const ScRange& rRange, const ::std::vector<SingleRangeData>& rData,
235  const TokenArrayRef& pArray);
236 
237  bool isDocInitialized(sal_uInt16 nFileId);
238  void initializeDoc(sal_uInt16 nFileId, const ::std::vector<OUString>& rTabNames, const OUString& rBaseName);
239  OUString getTableName(sal_uInt16 nFileId, size_t nCacheId) const;
240  void getAllTableNames(sal_uInt16 nFileId, ::std::vector<OUString>& rTabNames) const;
241  SCTAB getTabSpan( sal_uInt16 nFileId, const OUString& rStartTabName, const OUString& rEndTabName ) const;
242  void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
243 
249  bool setCacheDocReferenced( sal_uInt16 nFileId );
250 
255  bool setCacheTableReferenced( sal_uInt16 nFileId, const OUString& rTabName, size_t nSheets );
256  void setAllCacheTableReferencedStati( bool bReferenced );
258 
264  void getAllCachedDataSpans( const ScDocument& rSrcDoc, sal_uInt16 nFileId, sc::ColumnSpanSet& rSet ) const;
265 
266  bool getSrcDocTable( const ScDocument& rSrcDoc, const OUString& rTabName, SCTAB& rTab, sal_uInt16 nFileId ) const;
267 
268 private:
270  {
272  {
273  ::std::vector<bool> maTables;
275  // Initially, documents have no tables but all referenced.
276  DocReferenced() : mbAllTablesReferenced(true) {}
277  };
278  typedef ::std::vector<DocReferenced> DocReferencedVec;
279 
280  DocReferencedVec maDocs;
282 
284  void reset( size_t nDocs );
285  void checkAllDocs();
286 
287  } maReferenced;
288  void addCacheTableToReferenced( sal_uInt16 nFileId, size_t nIndex );
289  void addCacheDocToReferenced( sal_uInt16 nFileId );
290 public:
291 
292  ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const;
293  ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const OUString& rTabName, bool bCreateNew,
294  size_t* pnIndex, const OUString* pExtUrl);
295 
299  void clearCache(sal_uInt16 nFileId);
300 
305  void clearCacheTables(sal_uInt16 nFileId);
306 
307  // Get the doc used to pass to methods that need an ScDocument in order to do row/col validation
308  const ScDocument& getDoc() const { return mrDoc; }
309 
310 private:
311  struct RangeHash
312  {
313  size_t operator()(const ScRange& rRange) const
314  {
315  const ScAddress& s = rRange.aStart;
316  const ScAddress& e = rRange.aEnd;
317  size_t hash = 17;
318  hash = hash * 37 + s.Tab();
319  hash = hash * 37 + s.Col();
320  hash = hash * 37 + s.Row();
321  hash = hash * 37 + e.Tab();
322  hash = hash * 37 + e.Col();
323  hash = hash * 37 + e.Row();
324  return hash;
325  }
326  };
327 
328  typedef std::unordered_map<OUString, TokenArrayRef> RangeNameMap;
329  typedef std::unordered_map<ScRange, TokenArrayRef, RangeHash> RangeArrayMap;
330  typedef std::unordered_map<OUString, OUString> NamePairMap;
331 
333  struct DocItem
334  {
336  ::std::vector<TableTypeRef> maTables;
338  ::std::vector<TableName> maTableNames;
342  RangeNameMap maRangeNames;
344  RangeArrayMap maRangeArrays;
346  NamePairMap maRealRangeNameMap;
347 
352 
354 
355  DocItem() : mbInitFromSource(false) {}
356 
357  TableNameIndexMap::const_iterator findTableNameIndex( const OUString& rTabName ) const;
358  bool getTableDataIndex( const OUString& rTabName, size_t& rIndex ) const;
359  bool getSingleTableNameAlternative( OUString& rTabName ) const;
360  };
361  typedef std::unordered_map<sal_uInt16, DocItem> DocDataType;
362  DocItem* getDocItem(sal_uInt16 nFileId) const;
363 
364 private:
365  mutable osl::Mutex maMtxDocs;
366  mutable DocDataType maDocs;
368 };
369 
371 {
372 public:
373 
374  typedef std::set<ScFormulaCell*> RefCellSet;
375  typedef std::unordered_map<sal_uInt16, RefCellSet> RefCellMap;
376 
377  enum LinkUpdateType { LINK_MODIFIED, LINK_BROKEN, OH_NO_WE_ARE_GOING_TO_DIE };
378 
384  class SAL_DLLPRIVATE LinkListener
385  {
386  public:
387  LinkListener();
388  virtual ~LinkListener() COVERITY_NOEXCEPT_FALSE = 0;
389  virtual void notify(sal_uInt16 nFileId, LinkUpdateType eType) = 0;
390  };
391 
398  {
399  public:
400  ApiGuard(const ScDocument& rDoc);
401  ~ApiGuard();
402  private:
405  };
406 
407 private:
409  struct SrcShell
410  {
413 
414  SrcShell() : maLastAccess( tools::Time::SYSTEM ) {}
415  };
416 
417  typedef std::unordered_map<sal_uInt16, SrcShell> DocShellMap;
418  typedef std::unordered_map<sal_uInt16, bool> LinkedDocMap;
419 
420  typedef std::unordered_map<sal_uInt16, SvNumberFormatterMergeMap> NumFmtMap;
421 
423  typedef std::unordered_map<sal_uInt16, LinkListeners> LinkListenerMap;
424 
425 public:
427  struct SAL_DLLPRIVATE SrcFileData
428  {
429  OUString maFileName;
430  OUString maRealFileName;
431  OUString maRelativeName;
432  OUString maFilterName;
433  OUString maFilterOptions;
434 
435  void maybeCreateRealFileName(std::u16string_view rOwnDocName);
436  };
437 
438 public:
439  explicit ScExternalRefManager(ScDocument& rDoc);
440  virtual ~ScExternalRefManager() override;
441 
442  virtual OUString getCacheTableName(sal_uInt16 nFileId, size_t nTabIndex) const override;
443 
454  ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const;
455 
480  ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const OUString& rTabName, bool bCreateNew,
481  size_t* pnIndex = nullptr, const OUString* pExtUrl = nullptr);
482 
489  void getAllCachedTableNames(sal_uInt16 nFileId, ::std::vector<OUString>& rTabNames) const;
490 
506  SCTAB getCachedTabSpan(
507  sal_uInt16 nFileId, const OUString& rStartTabName, const OUString& rEndTabName) const;
508 
515  void getAllCachedNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
516 
517  sal_uInt16 getExternalFileCount() const;
518 
523  void markUsedByLinkListeners();
524 
525  void markUsedExternalRefCells();
526 
531  bool setCacheTableReferenced( sal_uInt16 nFileId, const OUString& rTabName, size_t nSheets );
532  void setAllCacheTableReferencedStati( bool bReferenced );
533 
538  bool isInReferenceMarking() const { return mbInReferenceMarking; }
539 
540  void storeRangeNameTokens(sal_uInt16 nFileId, const OUString& rName, const ScTokenArray& rArray);
541 
542  ScExternalRefCache::TokenRef getSingleRefToken(
543  sal_uInt16 nFileId, const OUString& rTabName, const ScAddress& rCell,
544  const ScAddress* pCurPos, SCTAB* pTab, ScExternalRefCache::CellFormat* pFmt = nullptr);
545 
559  ScExternalRefCache::TokenArrayRef getDoubleRefTokens(
560  sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange, const ScAddress* pCurPos);
561 
573  ScExternalRefCache::TokenArrayRef getRangeNameTokens(
574  sal_uInt16 nFileId, const OUString& rName, const ScAddress* pCurPos = nullptr);
575 
576  bool isValidRangeName(sal_uInt16 nFileId, const OUString& rName);
577 
578  OUString getOwnDocumentName() const;
579  bool isOwnDocument(std::u16string_view rFile) const;
580 
587  void convertToAbsName(OUString& rFile) const;
588  sal_uInt16 getExternalFileId(const OUString& rFile);
589 
603  const OUString* getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal = false);
604 
608  sal_uInt16 convertFileIdToUsedFileId(sal_uInt16 nFileId);
609  void setSkipUnusedFileIds(std::vector<sal_uInt16>& pExternFileIds);
610  void disableSkipUnusedFileIds();
611 
616  std::vector<OUString> getAllCachedExternalFileNames() const;
617 
618  bool hasExternalFile(sal_uInt16 nFileId) const;
619  bool hasExternalFile(const OUString& rFile) const;
620  const SrcFileData* getExternalFileData(sal_uInt16 nFileId) const;
621 
622  const OUString* getRealTableName(sal_uInt16 nFileId, const OUString& rTabName) const;
623  const OUString* getRealRangeName(sal_uInt16 nFileId, const OUString& rRangeName) const;
624  void clearCache(sal_uInt16 nFileId);
625  bool refreshSrcDocument(sal_uInt16 nFileId);
626  void breakLink(sal_uInt16 nFileId);
627  void switchSrcFile(sal_uInt16 nFileId, const OUString& rNewFile, const OUString& rNewFilter);
628 
636  void setRelativeFileName(sal_uInt16 nFileId, const OUString& rRelUrl);
637 
646  void setFilterData(sal_uInt16 nFileId, const OUString& rFilterName, const OUString& rOptions);
647 
648  void clear();
649 
650  bool hasExternalData() const;
651 
660  void resetSrcFileData(const OUString& rBaseFileUrl);
661 
665  void updateAbsAfterLoad();
666 
673  void removeRefCell(ScFormulaCell* pCell);
674 
680  void addLinkListener(sal_uInt16 nFileId, LinkListener* pListener);
681 
686  void removeLinkListener(sal_uInt16 nFileId, LinkListener* pListener);
687 
688  void removeLinkListener(LinkListener* pListener);
689 
696  void notifyAllLinkListeners(sal_uInt16 nFileId, LinkUpdateType eType);
697 
702  bool isFileLoadable(const OUString& rFile) const;
703 
704  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
705 
711  bool containsUnsavedReferences() const { return !maUnsavedDocShells.empty(); }
712 
713  void insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell);
717  void insertRefCellFromTemplate( ScFormulaCell* pTemplateCell, ScFormulaCell* pCell );
718 
719  bool hasCellExternalReference(const ScAddress& rCell);
720 
721  void enableDocTimer( bool bEnable );
722 
724  void addFilesToLinkManager();
725 
726 private:
728 
729  void refreshAllRefCells(sal_uInt16 nFileId);
730 
731  void fillCellFormat(sal_uLong nFmtIndex, ScExternalRefCache::CellFormat* pFmt) const;
732 
733  bool getSrcDocTable( const ScDocument& rSrcDoc, const OUString& rTabName, SCTAB& rTab, sal_uInt16 nFileId ) const;
734 
735  ScExternalRefCache::TokenRef getSingleRefTokenFromSrcDoc(
736  sal_uInt16 nFileId, ScDocument& rSrcDoc, const ScAddress& rPos,
738 
753  ScExternalRefCache::TokenArrayRef getDoubleRefTokensFromSrcDoc(
754  const ScDocument& rSrcDoc, const OUString& rTabName, ScRange& rRange,
755  ::std::vector<ScExternalRefCache::SingleRangeData>& rCacheData);
756 
769  static ScExternalRefCache::TokenArrayRef getRangeNameTokensFromSrcDoc(
770  sal_uInt16 nFileId, const ScDocument& rSrcDoc, OUString& rName);
771 
772  ScDocument* getInMemorySrcDocument(sal_uInt16 nFileId);
773  ScDocument* getSrcDocument(sal_uInt16 nFileId);
774  SfxObjectShellRef loadSrcDocument(sal_uInt16 nFileId, OUString& rFilter);
775 
779  ScDocument& cacheNewDocShell( sal_uInt16 nFileId, SrcShell& rSrcShell );
780 
781  void maybeLinkExternalFile( sal_uInt16 nFileId, bool bDeferFilterDetection = false );
782 
794  void maybeCreateRealFileName(sal_uInt16 nFileId);
795 
802  void purgeStaleSrcDocument(sal_Int32 nTimeOut);
803 
804  sal_uInt32 getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, const ScDocument& rSrcDoc);
805 
812  void transformUnsavedRefToSavedRef( SfxObjectShell* pShell );
813 
814 private:
816 
819 
824  DocShellMap maDocShells;
825 
830  DocShellMap maUnsavedDocShells;
831 
833  LinkedDocMap maLinkedDocs;
834 
839  RefCellMap maRefCells;
840 
841  LinkListenerMap maLinkListeners;
842 
843  NumFmtMap maNumFormatMap;
844 
849  std::vector<SrcFileData> maSrcFiles;
850 
852  bool mbInReferenceMarking:1;
853 
858  bool mbUserInteractionEnabled:1;
859 
860  bool mbSkipUnusedFileIds = false;
861  std::vector<sal_uInt16> maConvertFileIdToUsedFileId;
862 
863  bool mbDocTimerEnabled:1;
864 
866  DECL_DLLPRIVATE_LINK(TimeOutHdl, Timer*, void);
867 };
868 
869 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unordered_map< sal_uInt16, SrcShell > DocShellMap
bool setCacheDocReferenced(sal_uInt16 nFileId)
Set all tables of a document as referenced, used only during store-to-file.
const ScDocument & mrDoc
ScAddress aStart
Definition: address.hxx:497
SC_DLLPUBLIC void setCell(SCCOL nCol, SCROW nRow, TokenRef const &pToken, sal_uLong nFmtIndex=0, bool bSetCacheRange=true)
Add cell value to the cache.
void initializeDoc(sal_uInt16 nFileId, const ::std::vector< OUString > &rTabNames, const OUString &rBaseName)
std::unordered_map< sal_uInt16, SvNumberFormatterMergeMap > NumFmtMap
const ScDocument & getDoc() const
void getAllTableNames(sal_uInt16 nFileId,::std::vector< OUString > &rTabNames) const
SCROW Row() const
Definition: address.hxx:274
void clearCache(sal_uInt16 nFileId)
Clear all caches including the cache tables.
const OUString * getRealRangeName(sal_uInt16 nFileId, const OUString &rRangeName) const
bool setCacheTableReferenced(sal_uInt16 nFileId, const OUString &rTabName, size_t nSheets)
Set a table as referenced, used only during store-to-file.
std::set< ScFormulaCell * > RefCellSet
sal_uIntPtr sal_uLong
Source document meta-data container.
void getAllNumberFormats(::std::vector< sal_uInt32 > &rNumFmts) const
bool areAllCacheTablesReferenced() const
void setRangeNameTokens(sal_uInt16 nFileId, const OUString &rName, TokenArrayRef pArray)
SC_DLLPUBLIC void setWholeTableCached()
Call this to mark the entire table "cached".
ScAddress aEnd
Definition: address.hxx:498
std::unordered_map< sal_uInt16, RefCellSet > RefCellMap
Cache table for external reference data.
ScExternalRefManager * mpMgr
bool isValidRangeName(sal_uInt16 nFileId, const OUString &rName) const
bool isDocInitialized(sal_uInt16 nFileId)
TableNameIndexMap::const_iterator findTableNameIndex(const OUString &rTabName) const
ScRangeList maCachedRanges
Collection of individual cached ranges.
void getAllCols(SCROW nRow,::std::vector< SCCOL > &rCols, SCCOL nLow, SCCOL nHigh) const
Obtain a sorted vector of columns.
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.
OUString maRealFileName
original file name as loaded from the file.
TableName(const OUString &rUpper, const OUString &rReal)
ScExternalRefCache::TokenArrayRef getCellRangeData(sal_uInt16 nFileId, const OUString &rTabName, const ScRange &rRange)
Get a cached cell range data.
std::unordered_map< SCROW, RowDataType > RowsDataType
ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const OUString &rName)
bool containsUnsavedReferences() const
If we still contain unsaved files we should warn the user before saving.
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25
SCTAB Tab() const
Definition: address.hxx:283
void setReferenced(bool bReferenced)
Set/clear referenced status flag only if current status is not REFERENCED_PERMANENT.
void setCellData(sal_uInt16 nFileId, const OUString &rTabName, SCCOL nCol, SCROW nRow, TokenRef const &pToken, sal_uLong nFmtIndex)
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 getAllNumberFormats(::std::vector< sal_uInt32 > &rNumFmts) const
void getAllRows(::std::vector< SCROW > &rRows, SCROW nLow, SCROW nHigh) const
Obtain a sorted vector of rows.
::std::vector< DocReferenced > DocReferencedVec
DocumentType eType
struct ScExternalRefCache::ReferencedStatus maReferenced
SCTAB getTabSpan(sal_uInt16 nFileId, const OUString &rStartTabName, const OUString &rEndTabName) const
TokenRef getEmptyOrNullToken(SCCOL nCol, SCROW nRow) const
bool isRangeCached(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Base class for objects that need to listen to link updates.
SC_DLLPUBLIC TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32 *pnFmtIndex=nullptr) const
OUString maRelativeName
file name created from the relative name.
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...
void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, const OUString &rType=OUString("cell-change"), const css::uno::Sequence< css::beans::PropertyValue > &rProperties=css::uno::Sequence< css::beans::PropertyValue >())
Definition: docsh.hxx:483
ScExternalRefCache(const ScDocument &rDoc)
sal_Int16 SCCOL
Definition: types.hxx:21
NamePairMap maRealRangeNameMap
Upper- to real-case mapping for range names.
void setCellRangeData(sal_uInt16 nFileId, const ScRange &rRange, const ::std::vector< SingleRangeData > &rData, const TokenArrayRef &pArray)
CAUTION! The following defines must be in the same namespace as the respective type.
::std::vector< TableName > maTableNames
Table name list in correct order, in both upper- and real-case.
const OUString * getRealTableName(sal_uInt16 nFileId, const OUString &rTabName) const
bool isInReferenceMarking() const
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
std::unordered_map< OUString, OUString > NamePairMap
o3tl::sorted_vector< LinkListener * > LinkListeners
OUString maSingleTableNameAlias
Either the base name that was stored as sheet name for CSV files if sheet name is Sheet1...
::std::vector< TableTypeRef > maTables
The raw cache tables.
void clearCacheTables(sal_uInt16 nFileId)
Clear all caches but keep the tables.
SvNumFormatType
DocShellMap maUnsavedDocShells
DocShells to unsaved but referenced documents.
Represents a single cached table in an external document.
OUString maTableName
This name must be in upper-case.
Shell instance for a source document.
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, not the cached range metadata stored separately in the Table.
std::unordered_map< sal_uInt16, DocItem > DocDataType
LinkListenerMap maLinkListeners
ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const
RefCellMap maRefCells
List of referencing cells that may contain external names.
SCCOL Col() const
Definition: address.hxx:279
std::vector< SrcFileData > maSrcFiles
List of external source document meta-data, used to keep track of external document identifiers...
individual cell within cached external ref table.
bool getSrcDocTable(const ScDocument &rSrcDoc, const OUString &rTabName, SCTAB &rTab, sal_uInt16 nFileId) const
::formula::FormulaTokenRef TokenRef
sal_Int32 SCROW
Definition: types.hxx:17
std::unordered_map< ScRange, TokenArrayRef, RangeHash > RangeArrayMap
void setRangeName(sal_uInt16 nFileId, const OUString &rName)
size_t operator()(const ScRange &rRange) const
void setAllCacheTableReferencedStati(bool bReferenced)
OUString getTableName(sal_uInt16 nFileId, size_t nCacheId) const
DocItem * getDocItem(sal_uInt16 nFileId) const
std::shared_ptr< ScTokenArray > TokenArrayRef
std::shared_ptr< Table > TableTypeRef
void setCachedCellRange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
DocShellMap maDocShells
Source document cache.
bool hasRow(SCROW nRow) const
RowsDataType maRows
Data cache.
std::vector< sal_uInt16 > maConvertFileIdToUsedFileId
LinkedDocMap maLinkedDocs
list of source documents that are managed by the link manager.
bool getTableDataIndex(const OUString &rTabName, size_t &rIndex) const
std::unordered_map< sal_uInt16, bool > LinkedDocMap
std::unordered_map< OUString, size_t > TableNameIndexMap
std::unordered_map< OUString, TokenArrayRef > RangeNameMap
void addCacheDocToReferenced(sal_uInt16 nFileId)
ScExternalRefCache maRefCache
cache of referenced ranges and names from source documents.
bool isInCachedRanges(SCCOL nCol, SCROW nRow) const
void addCacheTableToReferenced(sal_uInt16 nFileId, size_t nIndex)
TableNameIndexMap maTableNameIndex
Table name to index map.
RangeArrayMap maRangeArrays
Token array cache for cell ranges.
RangeNameMap maRangeNames
Range name cache.
std::unordered_map< SCCOL, Cell > RowDataType
void setCachedCell(SCCOL nCol, SCROW nRow)
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
sal_Int16 SCTAB
Definition: types.hxx:22
Use this guard when performing something from the API that might query values from external reference...
bool m_bDetectedRangeSegmentation false
Represents data cached for a single external document.
bool getSingleTableNameAlternative(OUString &rTabName) const
std::unordered_map< sal_uInt16, LinkListeners > LinkListenerMap