Update ooo320-m1
[ooovba.git] / sc / source / filter / inc / xecontent.hxx
blobaeb6c130f37e11ba45377b94af7022a27c43c9ab
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: xecontent.hxx,v $
10 * $Revision: 1.14 $
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_XECONTENT_HXX
32 #define SC_XECONTENT_HXX
34 #include "rangelst.hxx"
35 #include "xlcontent.hxx"
36 #include "xladdress.hxx"
37 #include "xerecord.hxx"
38 #include "xeroot.hxx"
39 #include "xestring.hxx"
40 #include "xeformula.hxx"
42 /* ============================================================================
43 Classes to export the big Excel document contents (related to several cells or
44 globals for the sheet or document).
45 - Shared string table
46 - Merged cells
47 - Hyperlinks
48 - Label ranges
49 - Conditional formatting
50 - Data validation
51 - Web Queries
52 ============================================================================ */
54 // Shared string table ========================================================
56 class XclExpSstImpl;
58 /** Provides export of the SST (shared string table) record.
59 @descr Contains all strings in the document and writes the SST. */
60 class XclExpSst : public XclExpRecordBase
62 public:
63 explicit XclExpSst();
64 virtual ~XclExpSst();
66 /** Inserts a new string into the table.
67 @return The index of the string in the SST, used in other records. */
68 sal_uInt32 Insert( XclExpStringRef xString );
70 /** Writes the complete SST and EXTSST records. */
71 virtual void Save( XclExpStream& rStrm );
72 virtual void SaveXml( XclExpXmlStream& rStrm );
74 private:
75 typedef ::std::auto_ptr< XclExpSstImpl > XclExpSstImplPtr;
76 XclExpSstImplPtr mxImpl;
79 // Merged cells ===============================================================
81 /** Represents a MERGEDCELLS record containing all merged cell ranges in a sheet. */
82 class XclExpMergedcells : public XclExpRecordBase, protected XclExpRoot
84 public:
85 explicit XclExpMergedcells( const XclExpRoot& rRoot );
87 /** Appends a new range to the list of merged cell ranges. */
88 void AppendRange( const ScRange& rRange, sal_uInt32 nBaseXFId );
89 /** Returns the XF identifier of the top-left cell in a merged range. */
90 sal_uInt32 GetBaseXFId( const ScAddress& rPos ) const;
92 /** Writes the record, if it contains at least one merged cell range. */
93 virtual void Save( XclExpStream& rStrm );
94 virtual void SaveXml( XclExpXmlStream& rStrm );
96 private:
97 ScRangeList maMergedRanges; /// All merged cell ranges of the sheet.
98 ScfUInt32Vec maBaseXFIds; /// The XF identifiers of the top-left cells.
101 // Hyperlinks =================================================================
103 class SvxURLField;
104 class INetURLObject;
106 /** Provides export of hyperlink data. */
107 class XclExpHyperlink : public XclExpRecord
109 public:
110 /** Constructs the HLINK record from an URL text field. */
111 explicit XclExpHyperlink( const XclExpRoot& rRoot,
112 const SvxURLField& rUrlField, const ScAddress& rScPos );
113 virtual ~XclExpHyperlink();
115 /** Returns the cell representation text or 0, if not available. */
116 inline const String* GetRepr() const { return mxRepr.get(); }
118 virtual void SaveXml( XclExpXmlStream& rStrm );
120 virtual void WriteEmbeddedData( XclExpStream& rStrm );
121 private:
122 /** Builds file name from the passed file URL. Tries to convert to relative file name.
123 @param rnLevel (out-param) The parent directory level.
124 @param rbRel (out-param) true = path is relative. */
125 String BuildFileName(
126 sal_uInt16& rnLevel, bool& rbRel,
127 const String& rUrl, const XclExpRoot& rRoot ) const;
129 /** Writes the body of the HLINK record. */
130 virtual void WriteBody( XclExpStream& rStrm );
132 private:
133 typedef ::std::auto_ptr< String > StringPtr;
134 typedef ::std::auto_ptr< SvStream > SvStreamPtr;
136 ScAddress maScPos; /// Position of the hyperlink.
137 StringPtr mxRepr; /// Cell representation text.
138 SvStreamPtr mxVarData; /// Buffer stream with variable data.
139 sal_uInt32 mnFlags; /// Option flags.
140 XclExpStringRef mxTextMark; /// Location within mxRepr
141 ::rtl::OUString msTarget; /// Target URL
144 typedef XclExpRecordList< XclExpHyperlink > XclExpHyperlinkList;
146 // Label ranges ===============================================================
148 /** Provides export of the row/column label range list of a sheet. */
149 class XclExpLabelranges : public XclExpRecordBase, protected XclExpRoot
151 public:
152 /** Fills the cell range lists with all ranges of the current sheet. */
153 explicit XclExpLabelranges( const XclExpRoot& rRoot );
155 /** Writes the LABELRANGES record if it contains at least one range. */
156 virtual void Save( XclExpStream& rStrm );
158 private:
159 /** Fills the specified range list with all label headers of the current sheet.
160 @param rRanges The cell range list to fill.
161 @param xLabelRangesRef The core range list with all ranges.
162 @param nScTab The current Calc sheet index. */
163 void FillRangeList( ScRangeList& rScRanges,
164 ScRangePairListRef xLabelRangesRef, SCTAB nScTab );
166 private:
167 ScRangeList maRowRanges; /// Cell range list for row labels.
168 ScRangeList maColRanges; /// Cell range list for column labels.
171 // Conditional formatting =====================================================
173 class ScCondFormatEntry;
174 class XclExpCFImpl;
176 /** Represents a CF record that contains one condition of a conditional format. */
177 class XclExpCF : public XclExpRecord, protected XclExpRoot
179 public:
180 explicit XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry );
181 virtual ~XclExpCF();
183 private:
184 /** Writes the body of the CF record. */
185 virtual void WriteBody( XclExpStream& rStrm );
187 private:
188 typedef ::std::auto_ptr< XclExpCFImpl > XclExpCFImplPtr;
189 XclExpCFImplPtr mxImpl;
192 // ----------------------------------------------------------------------------
194 class ScConditionalFormat;
196 /** Represents a CONDFMT record that contains all conditions of a conditional format.
197 @descr Contains the conditions which are stored in CF records. */
198 class XclExpCondfmt : public XclExpRecord, protected XclExpRoot
200 public:
201 explicit XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat );
202 virtual ~XclExpCondfmt();
204 /** Returns true, if this conditional format contains at least one cell range and CF record. */
205 bool IsValid() const;
207 /** Writes the CONDFMT record with following CF records, if there is valid data. */
208 virtual void Save( XclExpStream& rStrm );
209 virtual void SaveXml( XclExpXmlStream& rStrm );
211 private:
212 /** Writes the body of the CONDFMT record. */
213 virtual void WriteBody( XclExpStream& rStrm );
215 private:
216 typedef XclExpRecordList< XclExpCF > XclExpCFList;
218 XclExpCFList maCFList; /// List of CF records.
219 XclRangeList maXclRanges; /// Cell ranges for this conditional format.
220 String msSeqRef; /// OOXML Sequence of References
223 // ----------------------------------------------------------------------------
225 /** Contains all conditional formats of a specific sheet. */
226 class XclExpCondFormatBuffer : public XclExpRecordBase, protected XclExpRoot
228 public:
229 /** Constructs CONDFMT and CF records containing the conditional formats of the current sheet. */
230 explicit XclExpCondFormatBuffer( const XclExpRoot& rRoot );
232 /** Writes all contained CONDFMT records with their CF records. */
233 virtual void Save( XclExpStream& rStrm );
234 virtual void SaveXml( XclExpXmlStream& rStrm );
236 private:
237 typedef XclExpRecordList< XclExpCondfmt > XclExpCondfmtList;
238 XclExpCondfmtList maCondfmtList; /// List of CONDFMT records.
241 // Data Validation ============================================================
243 class ScValidationData;
245 /** Provides export of the data of a DV record.
246 @descr This record contains the settings for a data validation. In detail
247 this is a pointer to the core validation data and a cell range list with all
248 affected cells. The handle index is used to optimize list search algorithm. */
249 class XclExpDV : public XclExpRecord, protected XclExpRoot
251 public:
252 explicit XclExpDV( const XclExpRoot& rRoot, ULONG nScHandle );
253 virtual ~XclExpDV();
255 /** Returns the core handle of the validation data. */
256 inline ULONG GetScHandle() const { return mnScHandle; }
258 /** Inserts a new cell range into the cell range list. */
259 void InsertCellRange( const ScRange& rPos );
260 /** Converts the Calc range list to the Excel range list.
261 @return false = Resulting range list empty - do not write this record. */
262 bool Finalize();
264 virtual void SaveXml( XclExpXmlStream& rStrm );
266 private:
267 /** Writes the body of the DV record. */
268 virtual void WriteBody( XclExpStream& rStrm );
270 private:
271 ScRangeList maScRanges; /// Calc range list with all affected cells.
272 XclRangeList maXclRanges; /// Excel range list with all affected cells.
273 XclExpString maPromptTitle; /// The prompt title.
274 XclExpString maPromptText; /// The prompt text.
275 XclExpString maErrorTitle; /// The error title.
276 XclExpString maErrorText; /// The error text.
277 XclExpStringRef mxString1; /// String for first condition formula.
278 XclTokenArrayRef mxTokArr1; /// Formula for first condition.
279 ::rtl::OUString msFormula1; /// OOXML Formula for first condition.
280 XclTokenArrayRef mxTokArr2; /// Formula for second condition.
281 ::rtl::OUString msFormula2; /// OOXML Formula for second condition.
282 sal_uInt32 mnFlags; /// Miscellaneous flags.
283 ULONG mnScHandle; /// The core handle for quick list search.
286 // ----------------------------------------------------------------------------
288 /** This class contains the DV record list following the DVAL record. */
289 class XclExpDval : public XclExpRecord, protected XclExpRoot
291 public:
292 explicit XclExpDval( const XclExpRoot& rRoot );
293 virtual ~XclExpDval();
295 /** Inserts the cell range into the range list of the DV record with the specified handle. */
296 void InsertCellRange( const ScRange& rRange, ULONG nScHandle );
298 /** Writes the DVAL record and the DV record list. */
299 virtual void Save( XclExpStream& rStrm );
300 virtual void SaveXml( XclExpXmlStream& rStrm );
302 private:
303 /** Searches for or creates a XclExpDV record object with the specified handle. */
304 XclExpDV& SearchOrCreateDv( ULONG nScHandle );
306 /** Writes the body of the DVAL record. */
307 virtual void WriteBody( XclExpStream& rStrm );
309 private:
310 typedef XclExpRecordList< XclExpDV > XclExpDVList;
311 typedef XclExpDVList::RecordRefType XclExpDVRef;
313 XclExpDVList maDVList; /// List of DV records
314 XclExpDVRef mxLastFoundDV; /// For search optimization.
317 // Web Queries ================================================================
319 /** Contains all records for a web query (linked tables in an HTML document).
320 @descr mode 1 (entire document): mpQryTables==0, mbEntireDoc==true;
321 mode 2 (all tables): mpQryTables==0, mbEntireDoc==false;
322 mode 3 (custom range list): mpQryTables!=0, mbEntireDoc==false. */
323 class XclExpWebQuery : public XclExpRecordBase
325 public:
326 /** Constructs a web query record container with settings from Calc. */
327 explicit XclExpWebQuery(
328 const String& rRangeName,
329 const String& rUrl,
330 const String& rSource,
331 sal_Int32 nRefrSecs );
332 virtual ~XclExpWebQuery();
334 /** Writes all needed records for this web query. */
335 virtual void Save( XclExpStream& rStrm );
337 private:
338 XclExpString maDestRange; /// Destination range.
339 XclExpString maUrl; /// Source document URL.
340 XclExpStringRef mxQryTables; /// List of source range names.
341 sal_Int16 mnRefresh; /// Refresh time in minutes.
342 bool mbEntireDoc; /// true = entire document.
345 // ----------------------------------------------------------------------------
347 /** Contains all web query records for this document. */
348 class XclExpWebQueryBuffer : public XclExpRecordList< XclExpWebQuery >
350 public:
351 explicit XclExpWebQueryBuffer( const XclExpRoot& rRoot );
354 // ============================================================================
356 #endif