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: xecontent.hxx,v $
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"
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).
49 - Conditional formatting
52 ============================================================================ */
54 // Shared string table ========================================================
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
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
);
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
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
);
97 ScRangeList maMergedRanges
; /// All merged cell ranges of the sheet.
98 ScfUInt32Vec maBaseXFIds
; /// The XF identifiers of the top-left cells.
101 // Hyperlinks =================================================================
106 /** Provides export of hyperlink data. */
107 class XclExpHyperlink
: public XclExpRecord
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
);
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
);
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
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
);
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
);
167 ScRangeList maRowRanges
; /// Cell range list for row labels.
168 ScRangeList maColRanges
; /// Cell range list for column labels.
171 // Conditional formatting =====================================================
173 class ScCondFormatEntry
;
176 /** Represents a CF record that contains one condition of a conditional format. */
177 class XclExpCF
: public XclExpRecord
, protected XclExpRoot
180 explicit XclExpCF( const XclExpRoot
& rRoot
, const ScCondFormatEntry
& rFormatEntry
);
184 /** Writes the body of the CF record. */
185 virtual void WriteBody( XclExpStream
& rStrm
);
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
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
);
212 /** Writes the body of the CONDFMT record. */
213 virtual void WriteBody( XclExpStream
& rStrm
);
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
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
);
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
252 explicit XclExpDV( const XclExpRoot
& rRoot
, ULONG nScHandle
);
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. */
264 virtual void SaveXml( XclExpXmlStream
& rStrm
);
267 /** Writes the body of the DV record. */
268 virtual void WriteBody( XclExpStream
& rStrm
);
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
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
);
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
);
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
326 /** Constructs a web query record container with settings from Calc. */
327 explicit XclExpWebQuery(
328 const String
& rRangeName
,
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
);
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
>
351 explicit XclExpWebQueryBuffer( const XclExpRoot
& rRoot
);
354 // ============================================================================