update dev300-m58
[ooovba.git] / sc / source / filter / inc / xelink.hxx
blob7da521f70a1ded268ec73b5ef290d86e76a80d63
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xelink.hxx,v $
10 * $Revision: 1.13.134.2 $
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_XELINK_HXX
32 #define SC_XELINK_HXX
34 #include "markdata.hxx"
35 #include "xllink.hxx"
36 #include "xerecord.hxx"
37 #include "xehelper.hxx"
38 #include "xeformula.hxx"
39 #include "externalrefmgr.hxx"
41 class ScRange;
42 struct ScSingleRefData;
43 struct ScComplexRefData;
45 /* ============================================================================
46 Classes for export of different kinds of internal/external references.
47 - 3D cell and cell range links
48 - External cell and cell range links
49 - External defined names
50 - Macro calls
51 - Add-in functions
52 - DDE links
53 - OLE object links
54 ============================================================================ */
56 // Excel sheet indexes ========================================================
58 /** Stores the correct Excel sheet index for each Calc sheet.
59 @descr The class knows all sheets which will not exported
60 (i.e. external link sheets, scenario sheets). */
61 class XclExpTabInfo : protected XclExpRoot
63 public:
64 /** Initializes the complete buffer from the current exported document. */
65 explicit XclExpTabInfo( const XclExpRoot& rRoot );
67 /** Returns true, if the specified Calc sheet will be exported. */
68 bool IsExportTab( SCTAB nScTab ) const;
69 /** Returns true, if the specified Calc sheet is used to store external cell contents. */
70 bool IsExternalTab( SCTAB nScTab ) const;
71 /** Returns true, if the specified Calc sheet is visible and will be exported. */
72 bool IsVisibleTab( SCTAB nScTab ) const;
73 /** Returns true, if the specified Calc sheet is selected and will be exported. */
74 bool IsSelectedTab( SCTAB nScTab ) const;
75 /** Returns true, if the specified Calc sheet is the displayed (active) sheet. */
76 bool IsDisplayedTab( SCTAB nScTab ) const;
77 /** Returns true, if the specified Calc sheet is displayed in right-to-left mode. */
78 bool IsMirroredTab( SCTAB nScTab ) const;
79 /** Returns the Calc name of the specified sheet. */
80 const String& GetScTabName( SCTAB nScTab ) const;
82 /** Returns the Excel sheet index for a given Calc sheet. */
83 sal_uInt16 GetXclTab( SCTAB nScTab ) const;
85 /** Returns the Calc sheet index of the nSortedTab-th entry in the sorted sheet names list. */
86 SCTAB GetRealScTab( SCTAB nSortedScTab ) const;
87 //UNUSED2009-05 /** Returns the index of the passed Calc sheet in the sorted sheet names list. */
88 //UNUSED2009-05 SCTAB GetSortedScTab( SCTAB nScTab ) const;
90 /** Returns the number of Calc sheets. */
91 inline SCTAB GetScTabCount() const { return mnScCnt; }
93 /** Returns the number of Excel sheets to be exported. */
94 inline sal_uInt16 GetXclTabCount() const { return mnXclCnt; }
95 /** Returns the number of external linked sheets. */
96 inline sal_uInt16 GetXclExtTabCount() const { return mnXclExtCnt; }
97 /** Returns the number of exported selected sheets. */
98 inline sal_uInt16 GetXclSelectedCount() const { return mnXclSelCnt; }
100 /** Returns the Excel index of the active, displayed sheet. */
101 inline sal_uInt16 GetDisplayedXclTab() const { return mnDisplXclTab; }
102 /** Returns the Excel index of the first visible sheet. */
103 inline sal_uInt16 GetFirstVisXclTab() const { return mnFirstVisXclTab; }
105 private:
106 /** Returns true, if any of the passed flags is set for the specified Calc sheet. */
107 bool GetFlag( SCTAB nScTab, sal_uInt8 nFlags ) const;
108 /** Sets or clears (depending on bSet) all passed flags for the specified Calc sheet. */
109 void SetFlag( SCTAB nScTab, sal_uInt8 nFlags, bool bSet = true );
111 /** Searches for sheets not to be exported. */
112 void CalcXclIndexes();
113 /** Sorts the names of all tables and stores the indexes of the sorted indexes. */
114 void CalcSortedIndexes();
116 private:
117 /** Data structure with infoemation about one Calc sheet. */
118 struct XclExpTabInfoEntry
120 String maScName;
121 sal_uInt16 mnXclTab;
122 sal_uInt8 mnFlags;
123 inline explicit XclExpTabInfoEntry() : mnXclTab( 0 ), mnFlags( 0 ) {}
126 typedef ::std::vector< XclExpTabInfoEntry > XclExpTabInfoVec;
127 typedef ::std::vector< SCTAB > ScTabVec;
129 XclExpTabInfoVec maTabInfoVec; /// Array of Calc sheet index information.
131 SCTAB mnScCnt; /// Count of Calc sheets.
132 sal_uInt16 mnXclCnt; /// Count of Excel sheets to be exported.
133 sal_uInt16 mnXclExtCnt; /// Count of external link sheets.
134 sal_uInt16 mnXclSelCnt; /// Count of selected and exported sheets.
135 sal_uInt16 mnDisplXclTab; /// Displayed (active) sheet.
136 sal_uInt16 mnFirstVisXclTab; /// First visible sheet.
138 ScTabVec maFromSortedVec; /// Sorted Calc sheet index -> real Calc sheet index.
139 ScTabVec maToSortedVec; /// Real Calc sheet index -> sorted Calc sheet index.
142 // Export link manager ========================================================
144 class XclExpLinkManagerImpl;
146 /** Stores all data for internal/external references (the link table). */
147 class XclExpLinkManager : public XclExpRecordBase, protected XclExpRoot
149 public:
150 explicit XclExpLinkManager( const XclExpRoot& rRoot );
151 virtual ~XclExpLinkManager();
153 /** Searches for an EXTERNSHEET index for the given Calc sheet.
154 @descr See above for the meaning of EXTERNSHEET indexes.
155 @param rnExtSheet (out-param) Returns the EXTERNSHEET index.
156 @param rnXclTab (out-param) Returns the Excel sheet index.
157 @param nScTab The Calc sheet index to process.
158 param pRefLogEntry If not 0, data about the external link is stored here. */
159 void FindExtSheet( sal_uInt16& rnExtSheet,
160 sal_uInt16& rnXclTab, SCTAB nScTab,
161 XclExpRefLogEntry* pRefLogEntry = 0 );
162 /** Searches for an EXTERNSHEET index for the given Calc sheet range.
163 @descr See above for the meaning of EXTERNSHEET indexes.
164 @param rnExtSheet (out-param) Returns the EXTERNSHEET index.
165 @param rnFirstXclTab (out-param) Returns the Excel sheet index of the first sheet.
166 @param rnXclTab (out-param) Returns the Excel sheet index of the last sheet.
167 @param nFirstScTab The first Calc sheet index to process.
168 @param nLastScTab The last Calc sheet index to process.
169 param pRefLogEntry If not 0, data about the external link is stored here. */
170 void FindExtSheet( sal_uInt16& rnExtSheet,
171 sal_uInt16& rnFirstXclTab, sal_uInt16& rnLastXclTab,
172 SCTAB nFirstScTab, SCTAB nLastScTab,
173 XclExpRefLogEntry* pRefLogEntry = 0 );
174 /** Searches for a special EXTERNSHEET index for the own document. */
175 sal_uInt16 FindExtSheet( sal_Unicode cCode );
177 void FindExtSheet( sal_uInt16 nFileId, const String& rTabName, sal_uInt16 nXclTabSpan,
178 sal_uInt16& rnExtSheet, sal_uInt16& rnFirstSBTab, sal_uInt16& rnLastSBTab,
179 XclExpRefLogEntry* pRefLogEntry = NULL );
181 /** Stores the cell with the given address in a CRN record list. */
182 void StoreCell( const ScSingleRefData& rRef );
183 /** Stores all cells in the given range in a CRN record list. */
184 void StoreCellRange( const ScComplexRefData& rRef );
186 void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef );
188 void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef );
190 /** Finds or inserts an EXTERNNAME record for an add-in function name.
191 @param rnExtSheet (out-param) Returns the index of the EXTSHEET structure for the add-in function name.
192 @param rnExtName (out-param) Returns the 1-based EXTERNNAME record index.
193 @return true = add-in function inserted; false = error (i.e. not supported in current BIFF). */
194 bool InsertAddIn(
195 sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
196 const String& rName );
197 /** InsertEuroTool */
198 bool InsertEuroTool(
199 sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
200 const String& rName );
201 /** Finds or inserts an EXTERNNAME record for DDE links.
202 @param rnExtSheet (out-param) Returns the index of the EXTSHEET structure for the DDE link.
203 @param rnExtName (out-param) Returns the 1-based EXTERNNAME record index.
204 @return true = DDE link inserted; false = error (i.e. not supported in current BIFF). */
205 bool InsertDde(
206 sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
207 const String& rApplic, const String& rTopic, const String& rItem );
209 bool InsertExtName(
210 sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rUrl,
211 const String& rName, const ScExternalRefCache::TokenArrayRef pArray );
213 /** Writes the entire Link table. */
214 virtual void Save( XclExpStream& rStrm );
216 private:
217 typedef ScfRef< XclExpLinkManagerImpl > XclExpLinkMgrImplPtr;
218 XclExpLinkMgrImplPtr mxImpl;
221 // ============================================================================
223 #endif