Update ooo320-m1
[ooovba.git] / sc / inc / externalrefmgr.hxx
blob22e114df41edc8482f634c8feb5c50f061fbe256
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: externalrefmgr.hxx,v $
10 * $Revision: 1.1.2.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_EXTERNALREFMGR_HXX
32 #define SC_EXTERNALREFMGR_HXX
34 #include "global.hxx"
35 #include "address.hxx"
36 #include "sfx2/objsh.hxx"
37 #include "sfx2/lnkbase.hxx"
38 #include "tools/time.hxx"
39 #include "vcl/timer.hxx"
40 #include "svtools/zforlist.hxx"
41 #include "scmatrix.hxx"
43 #include <hash_map>
44 #include <hash_set>
45 #include <boost/shared_ptr.hpp>
46 #include <vector>
47 #include <list>
48 #include <formula/ExternalReferenceHelper.hxx>
50 class ScDocument;
51 namespace formula
53 class FormulaToken;
55 class ScToken;
56 class ScMatrix;
57 class ScTokenArray;
58 class String;
59 class SfxObjectShellRef;
60 class Window;
62 class ScExternalRefCache;
64 class ScExternalRefLink : public ::sfx2::SvBaseLink
66 public:
67 ScExternalRefLink(ScDocument* pDoc, sal_uInt16 nFileId, const String& rFilter);
68 virtual ~ScExternalRefLink();
70 virtual void Closed();
71 virtual void DataChanged(const String& rMimeType, const ::com::sun::star::uno::Any & rValue);
72 virtual void Edit(Window* pParent, const Link& rEndEditHdl);
74 void SetDoReferesh(bool b);
76 private:
77 ScExternalRefLink(); // disabled
78 ScExternalRefLink(const ScExternalRefLink&); // disabled
80 DECL_LINK( ExternalRefEndEditHdl, ::sfx2::SvBaseLink* );
82 sal_uInt16 mnFileId;
83 String maFilterName;
84 ScDocument* mpDoc;
85 bool mbDoRefresh;
88 // ============================================================================
90 /**
91 * Cache table for external reference data.
93 class ScExternalRefCache
95 public:
96 typedef ::boost::shared_ptr< formula::FormulaToken> TokenRef;
97 typedef ::boost::shared_ptr<ScTokenArray> TokenArrayRef;
99 struct TableName
101 String maUpperName;
102 String maRealName;
104 explicit TableName(const String& rUppper, const String& rReal);
107 struct CellFormat
109 bool mbIsSet;
110 short mnType;
111 sal_uInt32 mnIndex;
113 explicit CellFormat();
116 private:
117 /** individual cell within cached external ref table. */
118 struct Cell
120 TokenRef mxToken;
121 sal_uInt32 mnFmtIndex;
123 typedef ::std::hash_map<SCCOL, Cell> RowDataType;
124 typedef ::std::hash_map<SCROW, RowDataType> RowsDataType;
126 public:
127 // SUNWS needs a forward declared friend, otherwise types and members
128 // of the outer class are not accessible.
129 class Table;
130 friend class ScExternalRefCache::Table;
132 class Table
134 public:
136 enum ReferencedFlag
138 UNREFERENCED,
139 REFERENCED_MARKED, // marked as referenced during store to file
140 REFERENCED_PERMANENT // permanently marked, e.g. from within interpreter
143 Table();
144 ~Table();
146 SC_DLLPUBLIC void setCell(SCCOL nCol, SCROW nRow, TokenRef pToken, sal_uInt32 nFmtIndex = 0);
147 TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex = NULL) const;
148 bool hasRow( SCROW nRow ) const;
149 /** Set/clear referenced status flag only if current status is not
150 REFERENCED_PERMANENT. */
151 void setReferenced( bool bReferenced );
152 /// Unconditionally set the reference status flag.
153 void setReferencedFlag( ReferencedFlag eFlag );
154 ReferencedFlag getReferencedFlag() const;
155 bool isReferenced() const;
156 /// Obtain a sorted vector of rows.
157 void getAllRows(::std::vector<SCROW>& rRows) const;
158 /// Obtain a sorted vector of columns.
159 void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols) const;
160 void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
162 private:
163 RowsDataType maRows;
164 ReferencedFlag meReferenced;
167 typedef ::boost::shared_ptr<Table> TableTypeRef;
168 typedef ::std::hash_map<String, size_t, ScStringHashCode> TableNameIndexMap;
170 ScExternalRefCache();
171 ~ScExternalRefCache();
173 const String* getRealTableName(sal_uInt16 nFileId, const String& rTabName) const;
174 const String* getRealRangeName(sal_uInt16 nFileId, const String& rRangeName) const;
177 * Get a cached cell data at specified cell location.
179 * @param nFileId file ID of an external document
180 * @param rTabName sheet name
181 * @param nCol
182 * @param nRow
184 * @return pointer to the token instance in the cache.
186 ScExternalRefCache::TokenRef getCellData(
187 sal_uInt16 nFileId, const String& rTabName, SCCOL nCol, SCROW nRow,
188 bool bEmptyCellOnNull, bool bWriteEmpty, sal_uInt32* pnFmtIndex);
191 * Get a cached cell range data.
193 * @return a new token array instance. Note that <i>the caller must
194 * manage the life cycle of the returned instance</i>, which is
195 * guaranteed if the TokenArrayRef is properly used..
197 ScExternalRefCache::TokenArrayRef getCellRangeData(
198 sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange, bool bEmptyCellOnNull, bool bWriteEmpty);
200 ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const String& rName);
201 void setRangeNameTokens(sal_uInt16 nFileId, const String& rName, TokenArrayRef pArray);
203 void setCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol, TokenRef pToken, sal_uInt32 nFmtIndex);
205 struct SingleRangeData
207 /** This name must be in upper-case. */
208 String maTableName;
209 ScMatrixRef mpRangeData;
211 void setCellRangeData(sal_uInt16 nFileId, const ScRange& rRange, const ::std::vector<SingleRangeData>& rData,
212 TokenArrayRef pArray);
214 bool isDocInitialized(sal_uInt16 nFileId);
215 void initializeDoc(sal_uInt16 nFileId, const ::std::vector<String>& rTabNames);
216 String getTableName(sal_uInt16 nFileId, size_t nCacheId) const;
217 void getAllTableNames(sal_uInt16 nFileId, ::std::vector<String>& rTabNames) const;
218 SCsTAB getTabSpan( sal_uInt16 nFileId, const String& rStartTabName, const String& rEndTabName ) const;
219 void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
220 bool hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const;
221 size_t getCacheTableCount(sal_uInt16 nFileId) const;
224 * Set all tables of a document as referenced, used only during
225 * store-to-file.
226 * @returns <TRUE/> if ALL tables of ALL documents are marked.
228 bool setCacheDocReferenced( sal_uInt16 nFileId );
231 * Set a table as referenced, used only during store-to-file.
232 * @returns <TRUE/> if ALL tables of ALL documents are marked.
234 bool setCacheTableReferenced( sal_uInt16 nFileId, const String& rTabName, size_t nSheets, bool bPermanent );
235 void setAllCacheTableReferencedStati( bool bReferenced );
236 bool areAllCacheTablesReferenced() const;
239 * Set a table as permanently referenced, to be called if not in
240 * mark-during-store-to-file cycle.
242 void setCacheTableReferencedPermanently( sal_uInt16 nFileId, const String& rTabName, size_t nSheets );
244 private:
245 struct ReferencedStatus
247 struct DocReferenced
249 ::std::vector<bool> maTables;
250 bool mbAllTablesReferenced;
251 // Initially, documents have no tables but all referenced.
252 DocReferenced() : mbAllTablesReferenced(true) {}
254 typedef ::std::vector<DocReferenced> DocReferencedVec;
256 DocReferencedVec maDocs;
257 bool mbAllReferenced;
259 ReferencedStatus();
260 explicit ReferencedStatus( size_t nDocs );
261 void reset( size_t nDocs );
262 void checkAllDocs();
264 } maReferenced;
265 void addCacheTableToReferenced( sal_uInt16 nFileId, size_t nIndex );
266 void addCacheDocToReferenced( sal_uInt16 nFileId );
267 public:
269 ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const;
270 ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const String& rTabName, bool bCreateNew, size_t* pnIndex);
272 void clearCache(sal_uInt16 nFileId);
274 private:
275 struct RangeHash
277 size_t operator()(const ScRange& rRange) const
279 const ScAddress& s = rRange.aStart;
280 const ScAddress& e = rRange.aEnd;
281 return s.Tab() + s.Col() + s.Row() + e.Tab() + e.Col() + e.Row();
285 typedef ::std::hash_map<String, TokenArrayRef, ScStringHashCode> RangeNameMap;
286 typedef ::std::hash_map<ScRange, TokenArrayRef, RangeHash> RangeArrayMap;
287 typedef ::std::hash_map<String, String, ScStringHashCode> NamePairMap;
289 // SUNWS needs a forward declared friend, otherwise types and members
290 // of the outer class are not accessible.
291 struct DocItem;
292 friend struct ScExternalRefCache::DocItem;
294 /** Represents data cached for a single external document. */
295 struct DocItem
297 /** The raw cache tables. */
298 ::std::vector<TableTypeRef> maTables;
299 /** Table name list in correct order, in both upper- and real-case. */
300 ::std::vector<TableName> maTableNames;
301 /** Table name to index map. The names must be stored upper-case. */
302 TableNameIndexMap maTableNameIndex;
303 /** Range name cache. */
304 RangeNameMap maRangeNames;
305 /** Token array cache for cell ranges. */
306 RangeArrayMap maRangeArrays;
307 /** Upper- to real-case mapping for range names. */
308 NamePairMap maRealRangeNameMap;
310 bool mbInitFromSource;
312 DocItem() : mbInitFromSource(false) {}
314 typedef ::std::hash_map<sal_uInt16, DocItem> DocDataType;
315 DocItem* getDocItem(sal_uInt16 nFileId) const;
317 private:
318 mutable DocDataType maDocs;
321 // ============================================================================
323 class SC_DLLPUBLIC ScExternalRefManager : public formula::ExternalReferenceHelper
325 public:
327 // SUNWS needs a forward declared friend, otherwise types and members
328 // of the outer class are not accessible.
329 class RefCells;
330 friend class ScExternalRefManager::RefCells;
332 /**
333 * Collection of cell addresses that contain external references. This
334 * data is used for link updates.
336 class RefCells
338 public:
339 RefCells();
340 ~RefCells();
342 void insertCell(const ScAddress& rAddr);
343 void removeCell(const ScAddress& rAddr);
344 void moveTable(SCTAB nOldTab, SCTAB nNewTab, bool bCopy);
345 void insertTable(SCTAB nPos);
346 void removeTable(SCTAB nPos);
347 void refreshAllCells(ScExternalRefManager& rRefMgr);
348 private:
350 typedef ::std::hash_set<SCROW> RowSet;
351 typedef ::std::hash_map<SCCOL, RowSet> ColSet;
353 // SUNWS needs a forward declared friend, otherwise types and members
354 // of the outer class are not accessible.
355 struct TabItem;
356 friend struct ScExternalRefManager::RefCells::TabItem;
358 struct TabItem
360 SCTAB mnIndex;
361 ColSet maCols;
362 explicit TabItem(SCTAB nIndex);
363 explicit TabItem(const TabItem& r);
365 typedef ::boost::shared_ptr<TabItem> TabItemRef;
367 /**
368 * Return the position that points either to the specified table
369 * position or to the position where a new table would be inserted in
370 * case the specified table is not present.
372 * @param nTab index of the desired table
374 ::std::list<TabItemRef>::iterator getTabPos(SCTAB nTab);
376 // This list must be sorted by the table index at all times.
377 ::std::list<TabItemRef> maTables;
380 enum LinkUpdateType { LINK_MODIFIED, LINK_BROKEN };
382 /**
383 * Base class for objects that need to listen to link updates. When a
384 * link to a certain external file is updated, the notify() method gets
385 * called.
387 class LinkListener
389 public:
390 LinkListener();
391 virtual ~LinkListener() = 0;
392 virtual void notify(sal_uInt16 nFileId, LinkUpdateType eType) = 0;
394 struct Hash
396 size_t operator() (const LinkListener* p) const
398 return reinterpret_cast<size_t>(p);
403 private:
404 /** Shell instance for a source document. */
405 struct SrcShell
407 SfxObjectShellRef maShell;
408 Time maLastAccess;
411 typedef ::std::hash_map<sal_uInt16, SrcShell> DocShellMap;
412 typedef ::std::hash_map<sal_uInt16, bool> LinkedDocMap;
414 typedef ::std::hash_map<sal_uInt16, RefCells> RefCellMap;
415 typedef ::std::hash_map<sal_uInt16, SvNumberFormatterMergeMap> NumFmtMap;
418 typedef ::std::hash_set<LinkListener*, LinkListener::Hash> LinkListeners;
419 typedef ::std::hash_map<sal_uInt16, LinkListeners> LinkListenerMap;
421 public:
422 /** Source document meta-data container. */
423 struct SrcFileData
425 String maFileName; /// original file name as loaded from the file.
426 String maRealFileName; /// file name created from the relative name.
427 String maRelativeName;
428 String maFilterName;
429 String maFilterOptions;
431 void maybeCreateRealFileName(const String& rOwnDocName);
434 public:
435 explicit ScExternalRefManager(ScDocument* pDoc);
436 virtual ~ScExternalRefManager();
438 virtual String getCacheTableName(sal_uInt16 nFileId, size_t nTabIndex) const;
441 * Get a cache table instance for specified table and table index. Unlike
442 * the other method that takes a table name, this method does not create a
443 * new table when a table is not available for specified index.
445 * @param nFileId file ID
446 * @param nTabIndex cache table index
448 * @return shared_ptr to the cache table instance
450 ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const;
453 * Get a cache table instance for specified file and table name. If the
454 * table instance is not already present, it'll instantiate a new one and
455 * append it to the end of the table array. <I>It's important to be
456 * aware of this fact especially for multi-table ranges for which
457 * table orders are critical.</I>
459 * Excel filter calls this method to populate the cache table from the
460 * XCT/CRN records.
462 * @param nFileId file ID
463 * @param rTabName table name
464 * @param bCreateNew if true, create a new table instance if it's not
465 * already present. If false, it returns NULL if the
466 * specified table's cache doesn't exist.
467 * @param pnIndex if non-NULL pointer is passed, it stores the internal
468 * index of a cache table instance.
470 * @return shared_ptr to the cache table instance
472 ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const String& rTabName, bool bCreateNew, size_t* pnIndex = 0);
473 void getAllCachedTableNames(sal_uInt16 nFileId, ::std::vector<String>& rTabNames) const;
476 * Get the span (distance+sign(distance)) of two sheets of a specified
477 * file.
479 * @param nFileId file ID
480 * @param rStartTabName name of first sheet (sheet1)
481 * @param rEndTabName name of second sheet (sheet2)
483 * @return span
484 * 1 if sheet2 == sheet1
485 * > 1 if sheet2 > sheet1
486 * < -1 if sheet2 < sheet1
487 * -1 if nFileId or rStartTabName not found
488 * 0 if rEndTabName not found
490 SCsTAB getCachedTabSpan( sal_uInt16 nFileId, const String& rStartTabName, const String& rEndTabName ) const;
492 /**
493 * Get all unique number format indices that are used in the cache tables.
494 * The retrieved indices are sorted in ascending order.
496 * @param rNumFmts (reference) all unique number format indices.
498 void getAllCachedNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
500 bool hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const;
501 size_t getCacheTableCount(sal_uInt16 nFileId) const;
502 sal_uInt16 getExternalFileCount() const;
505 * Mark all tables as referenced that are used by any LinkListener, used
506 * only during store-to-file.
507 * @returns <TRUE/> if ALL tables of ALL external documents are marked.
509 bool markUsedByLinkListeners();
512 * Set all tables of a document as referenced, used only during
513 * store-to-file.
514 * @returns <TRUE/> if ALL tables of ALL external documents are marked.
516 bool setCacheDocReferenced( sal_uInt16 nFileId );
519 * Set a table as referenced, used only during store-to-file.
520 * @returns <TRUE/> if ALL tables of ALL external documents are marked.
522 bool setCacheTableReferenced( sal_uInt16 nFileId, const String& rTabName, size_t nSheets );
523 void setAllCacheTableReferencedStati( bool bReferenced );
526 * Set a table as permanently referenced, to be called if not in
527 * mark-during-store-to-file cycle.
529 void setCacheTableReferencedPermanently( sal_uInt16 nFileId, const String& rTabName, size_t nSheets );
532 * @returns <TRUE/> if setAllCacheTableReferencedStati(false) was called,
533 * <FALSE/> if setAllCacheTableReferencedStati(true) was called.
535 bool isInReferenceMarking() const { return bInReferenceMarking; }
537 void storeRangeNameTokens(sal_uInt16 nFileId, const String& rName, const ScTokenArray& rArray);
539 ScExternalRefCache::TokenRef getSingleRefToken(
540 sal_uInt16 nFileId, const String& rTabName, const ScAddress& rCell,
541 const ScAddress* pCurPos, SCTAB* pTab, ScExternalRefCache::CellFormat* pFmt = NULL);
544 * Get an array of tokens that consist of the specified external cell
545 * range.
547 * @param nFileId file ID for an external document
548 * @param rTabName referenced sheet name
549 * @param rRange referenced cell range
550 * @param pCurPos current cursor position to keep track of cells that
551 * reference an external data.
553 * @return shared_ptr to a token array instance. <i>The caller must not
554 * delete the instance returned by this method.</i>
556 ScExternalRefCache::TokenArrayRef getDoubleRefTokens(sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange, const ScAddress* pCurPos);
559 * Get an array of tokens corresponding with a specified name in a
560 * specified file.
562 * @param pCurPos currnet cell address where this name token is used.
563 * This is purely to keep track of all cells containing
564 * external names for refreshing purposes. If this is
565 * NULL, then the cell will not be added to the list.
567 * @return shared_ptr to array of tokens composing the name
569 ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const String& rName, const ScAddress* pCurPos = NULL);
571 const String& getOwnDocumentName() const;
572 bool isOwnDocument(const String& rFile) const;
575 * Takes a flat file name, and convert it to an absolute URL path. An
576 * absolute URL path begines with 'file:///.
578 * @param rFile file name to convert
580 void convertToAbsName(String& rFile) const;
581 sal_uInt16 getExternalFileId(const String& rFile);
583 /**
584 * It returns a pointer to the name of the URI associated with a given
585 * external file ID. In case the original document has moved, it returns
586 * an URI adjusted for the relocation.
588 * @param nFileId file ID for an external document
589 * @param bForceOriginal If true, it always returns the original document
590 * URI even if the referring document has relocated.
591 * If false, it returns an URI adjusted for
592 * relocated document.
594 * @return const String* external document URI.
596 const String* getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal = false);
597 bool hasExternalFile(sal_uInt16 nFileId) const;
598 bool hasExternalFile(const String& rFile) const;
599 const SrcFileData* getExternalFileData(sal_uInt16 nFileId) const;
601 const String* getRealTableName(sal_uInt16 nFileId, const String& rTabName) const;
602 const String* getRealRangeName(sal_uInt16 nFileId, const String& rRangeName) const;
603 void refreshNames(sal_uInt16 nFileId);
604 void breakLink(sal_uInt16 nFileId);
605 void switchSrcFile(sal_uInt16 nFileId, const String& rNewFile, const String& rNewFilter);
607 /**
608 * Set a relative file path for the specified file ID. Note that the
609 * caller must ensure that the passed URL is a valid relative URL.
611 * @param nFileId file ID for an external document
612 * @param rRelUrl relative URL
614 void setRelativeFileName(sal_uInt16 nFileId, const String& rRelUrl);
617 * Set the filter name and options if any for a given source document.
618 * These values get reset when the source document ever gets reloaded.
620 * @param nFileId
621 * @param rFilterName
622 * @param rOptions
624 void setFilterData(sal_uInt16 nFileId, const String& rFilterName, const String& rOptions);
626 void clear();
628 bool hasExternalData() const;
631 * Re-generates relative names for all stored source files. This is
632 * necessary when exporting to an ods document, to ensure that all source
633 * files have their respective relative names for xlink:href export.
635 * @param rBaseFileUrl Absolute URL of the content.xml fragment of the
636 * document being exported.
638 void resetSrcFileData(const String& rBaseFileUrl);
640 /**
641 * Update a single referencing cell position.
643 * @param rOldPos old position
644 * @param rNewPos new position
646 void updateRefCell(const ScAddress& rOldPos, const ScAddress& rNewPos, bool bCopy);
648 /**
649 * Update referencing cells affected by sheet movement.
651 * @param nOldTab old sheet position
652 * @param nNewTab new sheet position
653 * @param bCopy whether this is a sheet move (false) or sheet copy (true)
655 void updateRefMoveTable(SCTAB nOldTab, SCTAB nNewTab, bool bCopy);
657 /**
658 * Update referencing cells affected by sheet insertion.
660 * @param nPos sheet insertion position. All sheets to the right
661 * including the one at the insertion poistion shift to the
662 * right by one.
664 void updateRefInsertTable(SCTAB nPos);
666 void updateRefDeleteTable(SCTAB nPos);
668 /**
669 * Register a new link listener to a specified external document. Note
670 * that the caller is responsible for managing the life cycle of the
671 * listener object.
673 void addLinkListener(sal_uInt16 nFileId, LinkListener* pListener);
675 /**
676 * Remove an existing link listener. Note that removing a listener
677 * pointer here does not delete the listener object instance.
679 void removeLinkListener(sal_uInt16 nFileId, LinkListener* pListener);
681 void removeLinkListener(LinkListener* pListener);
683 /**
684 * Notify all listeners that are listening to a specified external
685 * document.
687 * @param nFileId file ID for an external document.
689 void notifyAllLinkListeners(sal_uInt16 nFileId, LinkUpdateType eType);
691 private:
692 ScExternalRefManager();
693 ScExternalRefManager(const ScExternalRefManager&);
695 void refreshAllRefCells(sal_uInt16 nFileId);
697 void insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell);
699 ScDocument* getSrcDocument(sal_uInt16 nFileId);
700 SfxObjectShellRef loadSrcDocument(sal_uInt16 nFileId, String& rFilter);
701 bool isFileLoadable(const String& rFile) const;
703 void maybeLinkExternalFile(sal_uInt16 nFileId);
705 /**
706 * Try to create a "real" file name from the relative path. The original
707 * file name may not point to the real document when the referencing and
708 * referenced documents have been moved.
710 * For the real file name to be created, the relative name should not be
711 * empty before calling this method, or the real file name will not be
712 * created.
714 * @param nFileId file ID for an external document
716 void maybeCreateRealFileName(sal_uInt16 nFileId);
718 bool compileTokensByCell(const ScAddress& rCell);
721 * Purge those source document instances that have not been accessed for
722 * the specified duration.
724 * @param nTimeOut time out value in 100th of a second
726 void purgeStaleSrcDocument(sal_Int32 nTimeOut);
728 sal_uInt32 getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, ScDocument* pSrcDoc);
730 private:
731 /** cache of referenced ranges and names from source documents. */
732 ScExternalRefCache maRefCache;
734 ScDocument* mpDoc;
737 * Source document cache. This stores the original source document shell
738 * instances. They get purged after a certain period of time.
740 DocShellMap maDocShells;
742 /** list of source documents that are managed by the link manager. */
743 LinkedDocMap maLinkedDocs;
746 * List of referencing cells that may contain external names. There is
747 * one list per source document.
749 RefCellMap maRefCells;
751 LinkListenerMap maLinkListeners;
753 NumFmtMap maNumFormatMap;
755 /** original source file index. */
756 ::std::vector<SrcFileData> maSrcFiles;
758 /** Status whether in reference marking state. See isInReferenceMarking(). */
759 bool bInReferenceMarking;
761 AutoTimer maSrcDocTimer;
762 DECL_LINK(TimeOutHdl, AutoTimer*);
766 #endif