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 #ifndef INCLUDED_SC_INC_EXTERNALREFMGR_HXX
21 #define INCLUDED_SC_INC_EXTERNALREFMGR_HXX
22 
23 #include "address.hxx"
24 #include "document.hxx"
25 #include <sfx2/objsh.hxx>
26 #include <sfx2/lnkbase.hxx>
27 #include <tools/time.hxx>
28 #include <vcl/timer.hxx>
29 #include <svl/zforlist.hxx>
30 #include <svl/lstner.hxx>
31 #include "types.hxx"
32 #include "rangelst.hxx"
33 #include <osl/mutex.hxx>
34 #include <formula/types.hxx>
35 #include <tools/solar.h>
36 
37 #include <memory>
38 #include <unordered_map>
39 #include <unordered_set>
40 #include <vector>
41 #include <set>
42 #include <o3tl/sorted_vector.hxx>
44 
45 class ScTokenArray;
46 namespace weld { class Window; }
47 
48 class ScFormulaCell;
49 
50 namespace sc {
51 
52 class ColumnSpanSet;
53 
54 }
55 
57 {
58 public:
59  ScExternalRefLink(ScDocument* pDoc, sal_uInt16 nFileId);
60  virtual ~ScExternalRefLink() override;
61 
62  virtual void Closed() override;
63  virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
64  const OUString& rMimeType, const css::uno::Any & rValue) override;
65  virtual void Edit(weld::Window* pParent, const Link<SvBaseLink&,void>& rEndEditHdl) override;
66 
67  void SetDoReferesh(bool b);
68 
69 private:
70  ScExternalRefLink() = delete;
71  ScExternalRefLink(const ScExternalRefLink&) = delete;
72 
73  sal_uInt16 mnFileId;
76 };
77 
82 {
83 public:
84  typedef ::formula::FormulaTokenRef TokenRef;
85  typedef std::shared_ptr<ScTokenArray> TokenArrayRef;
86 
87  struct TableName
88  {
89  OUString maUpperName;
90  OUString maRealName;
91 
92  explicit TableName(const OUString& rUppper, const OUString& rReal);
93  };
94 
95  struct CellFormat
96  {
97  bool mbIsSet;
100 
101  explicit CellFormat();
102  };
103 
104 private:
106  struct Cell
107  {
108  TokenRef mxToken;
110  };
111  typedef std::unordered_map<SCCOL, Cell> RowDataType;
112  typedef std::unordered_map<SCROW, RowDataType> RowsDataType;
113 
114 public:
124  class Table
125  {
126  public:
127 
128  Table();
129  ~Table();
130 
131  void clear();
132 
140  SC_DLLPUBLIC void setCell(SCCOL nCol, SCROW nRow, TokenRef const & pToken, sal_uLong nFmtIndex = 0, bool bSetCacheRange = true);
141  SC_DLLPUBLIC TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex = nullptr) const;
142  bool hasRow( SCROW nRow ) const;
145  void setReferenced( bool bReferenced );
146  bool isReferenced() const;
148  void getAllRows(::std::vector<SCROW>& rRows, SCROW nLow = 0, SCROW nHigh = MAXROW) const;
150  SC_DLLPUBLIC ::std::pair< SCROW, SCROW > getRowRange() const;
152  void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols, SCCOL nLow = 0, SCCOL nHigh = MAXCOL) const;
154  SC_DLLPUBLIC ::std::pair< SCCOL, SCCOL > getColRange( SCROW nRow ) const;
155  void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
156  bool isRangeCached(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
157 
158  void setCachedCell(SCCOL nCol, SCROW nRow);
159  void setCachedCellRange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
160 
169  private:
170  bool isInCachedRanges(SCCOL nCol, SCROW nRow) const;
171  TokenRef getEmptyOrNullToken(SCCOL nCol, SCROW nRow) const;
172 
173  private:
175  RowsDataType maRows;
180  };
181 
182  typedef std::shared_ptr<Table> TableTypeRef;
183  typedef std::unordered_map< OUString, size_t>
185 
188 
189  const OUString* getRealTableName(sal_uInt16 nFileId, const OUString& rTabName) const;
190  const OUString* getRealRangeName(sal_uInt16 nFileId, const OUString& rRangeName) const;
191 
203  sal_uInt16 nFileId, const OUString& rTabName, SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex);
204 
213  sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange);
214 
215  ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const OUString& rName);
216  void setRangeNameTokens(sal_uInt16 nFileId, const OUString& rName, TokenArrayRef pArray);
217  bool isValidRangeName(sal_uInt16 nFileId, const OUString& rName) const;
218  void setRangeName(sal_uInt16 nFileId, const OUString& rName);
219 
220  void setCellData(sal_uInt16 nFileId, const OUString& rTabName,
221  SCCOL nCol, SCROW nRow, TokenRef const & pToken, sal_uLong nFmtIndex);
222 
224  {
226  OUString maTableName;
228  };
229  void setCellRangeData(sal_uInt16 nFileId, const ScRange& rRange, const ::std::vector<SingleRangeData>& rData,
230  const TokenArrayRef& pArray);
231 
232  bool isDocInitialized(sal_uInt16 nFileId);
233  void initializeDoc(sal_uInt16 nFileId, const ::std::vector<OUString>& rTabNames, const OUString& rBaseName);
234  OUString getTableName(sal_uInt16 nFileId, size_t nCacheId) const;
235  void getAllTableNames(sal_uInt16 nFileId, ::std::vector<OUString>& rTabNames) const;
236  SCTAB getTabSpan( sal_uInt16 nFileId, const OUString& rStartTabName, const OUString& rEndTabName ) const;
237  void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
238 
244  bool setCacheDocReferenced( sal_uInt16 nFileId );
245 
250  bool setCacheTableReferenced( sal_uInt16 nFileId, const OUString& rTabName, size_t nSheets );
251  void setAllCacheTableReferencedStati( bool bReferenced );
253 
259  void getAllCachedDataSpans( const ScDocument& rSrcDoc, sal_uInt16 nFileId, sc::ColumnSpanSet& rSet ) const;
260 
261  bool getSrcDocTable( const ScDocument& rSrcDoc, const OUString& rTabName, SCTAB& rTab, sal_uInt16 nFileId ) const;
262 
263 private:
265  {
267  {
268  ::std::vector<bool> maTables;
270  // Initially, documents have no tables but all referenced.
271  DocReferenced() : mbAllTablesReferenced(true) {}
272  };
273  typedef ::std::vector<DocReferenced> DocReferencedVec;
274 
275  DocReferencedVec maDocs;
277 
279  void reset( size_t nDocs );
280  void checkAllDocs();
281 
282  } maReferenced;
283  void addCacheTableToReferenced( sal_uInt16 nFileId, size_t nIndex );
284  void addCacheDocToReferenced( sal_uInt16 nFileId );
285 public:
286 
287  ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const;
288  ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const OUString& rTabName, bool bCreateNew,
289  size_t* pnIndex, const OUString* pExtUrl);
290 
294  void clearCache(sal_uInt16 nFileId);
295 
300  void clearCacheTables(sal_uInt16 nFileId);
301 
302  // Get the fake doc used to pass to methods that need an ScDocument in order to do row/col validation
303  const ScDocument* getFakeDoc() const { return mxFakeDoc.get(); }
304 
305 private:
306  struct RangeHash
307  {
308  size_t operator()(const ScRange& rRange) const
309  {
310  const ScAddress& s = rRange.aStart;
311  const ScAddress& e = rRange.aEnd;
312  size_t hash = 17;
313  hash = hash * 37 + s.Tab();
314  hash = hash * 37 + s.Col();
315  hash = hash * 37 + s.Row();
316  hash = hash * 37 + e.Tab();
317  hash = hash * 37 + e.Col();
318  hash = hash * 37 + e.Row();
319  return hash;
320  }
321  };
322 
323  typedef std::unordered_map<OUString, TokenArrayRef> RangeNameMap;
324  typedef std::unordered_map<ScRange, TokenArrayRef, RangeHash> RangeArrayMap;
325  typedef std::unordered_map<OUString, OUString> NamePairMap;
326 
328  struct DocItem
329  {
331  ::std::vector<TableTypeRef> maTables;
333  ::std::vector<TableName> maTableNames;
337  RangeNameMap maRangeNames;
339  RangeArrayMap maRangeArrays;
341  NamePairMap maRealRangeNameMap;
342 
347 
349 
350  DocItem() : mbInitFromSource(false) {}
351 
352  TableNameIndexMap::const_iterator findTableNameIndex( const OUString& rTabName ) const;
353  bool getTableDataIndex( const OUString& rTabName, size_t& rIndex ) const;
354  bool getSingleTableNameAlternative( OUString& rTabName ) const;
355  };
356  typedef std::unordered_map<sal_uInt16, DocItem> DocDataType;
357  DocItem* getDocItem(sal_uInt16 nFileId) const;
358 
359 private:
360  mutable osl::Mutex maMtxDocs;
361  mutable DocDataType maDocs;
362  ScDocumentUniquePtr mxFakeDoc; // just to have something to pass to the methods that need to validate columns/rows
363 };
364 
366 {
367 public:
368 
369  typedef std::set<ScFormulaCell*> RefCellSet;
370  typedef std::unordered_map<sal_uInt16, RefCellSet> RefCellMap;
371 
372  enum LinkUpdateType { LINK_MODIFIED, LINK_BROKEN };
373 
379  class SAL_DLLPRIVATE LinkListener
380  {
381  public:
382  LinkListener();
383  virtual ~LinkListener() COVERITY_NOEXCEPT_FALSE = 0;
384  virtual void notify(sal_uInt16 nFileId, LinkUpdateType eType) = 0;
385  };
386 
393  {
394  public:
395  ApiGuard(const ScDocument* pDoc);
396  ~ApiGuard();
397  private:
400  };
401 
402 private:
404  struct SrcShell
405  {
408 
409  SrcShell() : maLastAccess( tools::Time::SYSTEM ) {}
410  };
411 
412  typedef std::unordered_map<sal_uInt16, SrcShell> DocShellMap;
413  typedef std::unordered_map<sal_uInt16, bool> LinkedDocMap;
414 
415  typedef std::unordered_map<sal_uInt16, SvNumberFormatterMergeMap> NumFmtMap;
416 
418  typedef std::unordered_map<sal_uInt16, LinkListeners> LinkListenerMap;
419 
420 public:
422  struct SAL_DLLPRIVATE SrcFileData
423  {
424  OUString maFileName;
425  OUString maRealFileName;
426  OUString maRelativeName;
427  OUString maFilterName;
428  OUString maFilterOptions;
429 
430  void maybeCreateRealFileName(const OUString& rOwnDocName);
431  };
432 
433 public:
434  explicit ScExternalRefManager(ScDocument* pDoc);
435  virtual ~ScExternalRefManager() override;
436 
437  virtual OUString getCacheTableName(sal_uInt16 nFileId, size_t nTabIndex) const override;
438 
449  ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const;
450 
475  ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const OUString& rTabName, bool bCreateNew,
476  size_t* pnIndex = nullptr, const OUString* pExtUrl = nullptr);
477 
484  void getAllCachedTableNames(sal_uInt16 nFileId, ::std::vector<OUString>& rTabNames) const;
485 
501  SCTAB getCachedTabSpan(
502  sal_uInt16 nFileId, const OUString& rStartTabName, const OUString& rEndTabName) const;
503 
510  void getAllCachedNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
511 
512  sal_uInt16 getExternalFileCount() const;
513 
518  void markUsedByLinkListeners();
519 
520  void markUsedExternalRefCells();
521 
526  bool setCacheTableReferenced( sal_uInt16 nFileId, const OUString& rTabName, size_t nSheets );
527  void setAllCacheTableReferencedStati( bool bReferenced );
528 
533  bool isInReferenceMarking() const { return mbInReferenceMarking; }
534 
535  void storeRangeNameTokens(sal_uInt16 nFileId, const OUString& rName, const ScTokenArray& rArray);
536 
537  ScExternalRefCache::TokenRef getSingleRefToken(
538  sal_uInt16 nFileId, const OUString& rTabName, const ScAddress& rCell,
539  const ScAddress* pCurPos, SCTAB* pTab, ScExternalRefCache::CellFormat* pFmt = nullptr);
540 
554  ScExternalRefCache::TokenArrayRef getDoubleRefTokens(
555  sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange, const ScAddress* pCurPos);
556 
568  ScExternalRefCache::TokenArrayRef getRangeNameTokens(
569  sal_uInt16 nFileId, const OUString& rName, const ScAddress* pCurPos = nullptr);
570 
571  bool isValidRangeName(sal_uInt16 nFileId, const OUString& rName);
572 
573  OUString getOwnDocumentName() const;
574  bool isOwnDocument(const OUString& rFile) const;
575 
582  void convertToAbsName(OUString& rFile) const;
583  sal_uInt16 getExternalFileId(const OUString& rFile);
584 
598  const OUString* getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal = false);
599 
604  std::vector<OUString> getAllCachedExternalFileNames() const;
605 
606  bool hasExternalFile(sal_uInt16 nFileId) const;
607  bool hasExternalFile(const OUString& rFile) const;
608  const SrcFileData* getExternalFileData(sal_uInt16 nFileId) const;
609 
610  const OUString* getRealTableName(sal_uInt16 nFileId, const OUString& rTabName) const;
611  const OUString* getRealRangeName(sal_uInt16 nFileId, const OUString& rRangeName) const;
612  void clearCache(sal_uInt16 nFileId);
613  bool refreshSrcDocument(sal_uInt16 nFileId);
614  void breakLink(sal_uInt16 nFileId);
615  void switchSrcFile(sal_uInt16 nFileId, const OUString& rNewFile, const OUString& rNewFilter);
616 
624  void setRelativeFileName(sal_uInt16 nFileId, const OUString& rRelUrl);
625 
634  void setFilterData(sal_uInt16 nFileId, const OUString& rFilterName, const OUString& rOptions);
635 
636  void clear();
637 
638  bool hasExternalData() const;
639 
648  void resetSrcFileData(const OUString& rBaseFileUrl);
649 
653  void updateAbsAfterLoad();
654 
661  void removeRefCell(ScFormulaCell* pCell);
662 
668  void addLinkListener(sal_uInt16 nFileId, LinkListener* pListener);
669 
674  void removeLinkListener(sal_uInt16 nFileId, LinkListener* pListener);
675 
676  void removeLinkListener(LinkListener* pListener);
677 
684  void notifyAllLinkListeners(sal_uInt16 nFileId, LinkUpdateType eType);
685 
690  bool isFileLoadable(const OUString& rFile) const;
691 
692  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
693 
699  bool containsUnsavedReferences() const { return !maUnsavedDocShells.empty(); }
700 
701  void insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell);
705  void insertRefCellFromTemplate( ScFormulaCell* pTemplateCell, ScFormulaCell* pCell );
706 
707  bool hasCellExternalReference(const ScAddress& rCell);
708 
709  void enableDocTimer( bool bEnable );
710 
712  void addFilesToLinkManager();
713 
714 private:
716 
717  void refreshAllRefCells(sal_uInt16 nFileId);
718 
719  void fillCellFormat(sal_uLong nFmtIndex, ScExternalRefCache::CellFormat* pFmt) const;
720 
721  bool getSrcDocTable( const ScDocument& rSrcDoc, const OUString& rTabName, SCTAB& rTab, sal_uInt16 nFileId ) const;
722 
723  ScExternalRefCache::TokenRef getSingleRefTokenFromSrcDoc(
724  sal_uInt16 nFileId, ScDocument* pSrcDoc, const ScAddress& rPos,
726 
741  ScExternalRefCache::TokenArrayRef getDoubleRefTokensFromSrcDoc(
742  const ScDocument* pSrcDoc, const OUString& rTabName, ScRange& rRange,
743  ::std::vector<ScExternalRefCache::SingleRangeData>& rCacheData);
744 
757  static ScExternalRefCache::TokenArrayRef getRangeNameTokensFromSrcDoc(
758  sal_uInt16 nFileId, const ScDocument* pSrcDoc, OUString& rName);
759 
760  ScDocument* getInMemorySrcDocument(sal_uInt16 nFileId);
761  ScDocument* getSrcDocument(sal_uInt16 nFileId);
762  SfxObjectShellRef loadSrcDocument(sal_uInt16 nFileId, OUString& rFilter);
763 
767  ScDocument& cacheNewDocShell( sal_uInt16 nFileId, SrcShell& rSrcShell );
768 
769  void maybeLinkExternalFile( sal_uInt16 nFileId, bool bDeferFilterDetection = false );
770 
782  void maybeCreateRealFileName(sal_uInt16 nFileId);
783 
790  void purgeStaleSrcDocument(sal_Int32 nTimeOut);
791 
792  sal_uInt32 getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, const ScDocument* pSrcDoc);
793 
800  void transformUnsavedRefToSavedRef( SfxObjectShell* pShell );
801 
802 private:
804 
807 
812  DocShellMap maDocShells;
813 
818  DocShellMap maUnsavedDocShells;
819 
821  LinkedDocMap maLinkedDocs;
822 
827  RefCellMap maRefCells;
828 
829  LinkListenerMap maLinkListeners;
830 
831  NumFmtMap maNumFormatMap;
832 
837  std::vector<SrcFileData> maSrcFiles;
838 
840  bool mbInReferenceMarking:1;
841 
846  bool mbUserInteractionEnabled:1;
847 
848  bool mbDocTimerEnabled:1;
849 
851  DECL_LINK(TimeOutHdl, Timer*, void);
852 };
853 
854 #endif
855 
856 /* 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.
ScAddress aStart
Definition: address.hxx:500
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
void getAllTableNames(sal_uInt16 nFileId,::std::vector< OUString > &rTabNames) const
SCROW Row() const
Definition: address.hxx:262
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:501
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
void getAllCols(SCROW nRow,::std::vector< SCCOL > &rCols, SCCOL nLow=0, SCCOL nHigh=MAXCOL) const
Obtain a sorted vector of columns.
ScRangeList maCachedRanges
Collection of individual cached ranges.
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.
css::uno::Any const & rValue
OUString maRealFileName
original file name as loaded from the file.
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)
const SCROW MAXROW
Definition: address.hxx:69
bool containsUnsavedReferences() const
If we still contain unsaved files we should warn the user before saving.
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:26
SCTAB Tab() const
Definition: address.hxx:271
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
::std::vector< DocReferenced > DocReferencedVec
DocumentType eType
void getAllRows(::std::vector< SCROW > &rRows, SCROW nLow=0, SCROW nHigh=MAXROW) const
Obtain a sorted vector of rows.
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:477
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2618
sal_Int16 SCCOL
Definition: types.hxx:22
const SCCOL MAXCOL
Definition: address.hxx:70
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)
::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:267
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:18
std::unordered_map< ScRange, TokenArrayRef, RangeHash > RangeArrayMap
void setRangeName(sal_uInt16 nFileId, const OUString &rName)
ScDocumentUniquePtr mxFakeDoc
size_t operator()(const ScRange &rRange) const
void setAllCacheTableReferencedStati(bool bReferenced)
OUString getTableName(sal_uInt16 nFileId, size_t nCacheId) const
const ScDocument * getFakeDoc() 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.
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:28
sal_Int16 SCTAB
Definition: types.hxx:23
Use this guard when performing something from the API that might query values from external reference...
TableName(const OUString &rUppper, const OUString &rReal)
Represents data cached for a single external document.
bool getSingleTableNameAlternative(OUString &rTabName) const
std::unordered_map< sal_uInt16, LinkListeners > LinkListenerMap