1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SC_XECONTENT_HXX
29 #define SC_XECONTENT_HXX
31 #include "rangelst.hxx"
32 #include "xlcontent.hxx"
33 #include "xladdress.hxx"
34 #include "xerecord.hxx"
36 #include "xestring.hxx"
37 #include "xeformula.hxx"
39 /* ============================================================================
40 Classes to export the big Excel document contents (related to several cells or
41 globals for the sheet or document).
46 - Conditional formatting
49 ============================================================================ */
51 // Shared string table ========================================================
55 /** Provides export of the SST (shared string table) record.
56 @descr Contains all strings in the document and writes the SST. */
57 class XclExpSst
: public XclExpRecordBase
63 /** Inserts a new string into the table.
64 @return The index of the string in the SST, used in other records. */
65 sal_uInt32
Insert( XclExpStringRef xString
);
67 /** Writes the complete SST and EXTSST records. */
68 virtual void Save( XclExpStream
& rStrm
);
69 virtual void SaveXml( XclExpXmlStream
& rStrm
);
72 typedef ::std::auto_ptr
< XclExpSstImpl
> XclExpSstImplPtr
;
73 XclExpSstImplPtr mxImpl
;
76 // Merged cells ===============================================================
78 /** Represents a MERGEDCELLS record containing all merged cell ranges in a sheet. */
79 class XclExpMergedcells
: public XclExpRecordBase
, protected XclExpRoot
82 explicit XclExpMergedcells( const XclExpRoot
& rRoot
);
84 /** Appends a new range to the list of merged cell ranges. */
85 void AppendRange( const ScRange
& rRange
, sal_uInt32 nBaseXFId
);
86 /** Returns the XF identifier of the top-left cell in a merged range. */
87 sal_uInt32
GetBaseXFId( const ScAddress
& rPos
) const;
89 /** Writes the record, if it contains at least one merged cell range. */
90 virtual void Save( XclExpStream
& rStrm
);
91 virtual void SaveXml( XclExpXmlStream
& rStrm
);
94 ScRangeList maMergedRanges
; /// All merged cell ranges of the sheet.
95 ScfUInt32Vec maBaseXFIds
; /// The XF identifiers of the top-left cells.
98 // Hyperlinks =================================================================
103 /** Provides export of hyperlink data. */
104 class XclExpHyperlink
: public XclExpRecord
107 /** Constructs the HLINK record from an URL text field. */
108 explicit XclExpHyperlink( const XclExpRoot
& rRoot
,
109 const SvxURLField
& rUrlField
, const ScAddress
& rScPos
);
110 virtual ~XclExpHyperlink();
112 /** Returns the cell representation text or 0, if not available. */
113 inline const String
* GetRepr() const { return mxRepr
.get(); }
115 virtual void SaveXml( XclExpXmlStream
& rStrm
);
117 /** Builds file name from the passed file URL. Tries to convert to relative file name.
118 @param rnLevel (out-param) The parent directory level.
119 @param rbRel (out-param) true = path is relative. */
120 String
BuildFileName(
121 sal_uInt16
& rnLevel
, bool& rbRel
,
122 const String
& rUrl
, const XclExpRoot
& rRoot
) const;
124 /** Writes the body of the HLINK record. */
125 virtual void WriteBody( XclExpStream
& rStrm
);
128 typedef ::std::auto_ptr
< String
> StringPtr
;
129 typedef ::std::auto_ptr
< SvStream
> SvStreamPtr
;
131 ScAddress maScPos
; /// Position of the hyperlink.
132 StringPtr mxRepr
; /// Cell representation text.
133 SvStreamPtr mxVarData
; /// Buffer stream with variable data.
134 sal_uInt32 mnFlags
; /// Option flags.
135 XclExpStringRef mxTextMark
; /// Location within mxRepr
136 ::rtl::OUString msTarget
; /// Target URL
139 typedef XclExpRecordList
< XclExpHyperlink
> XclExpHyperlinkList
;
141 // Label ranges ===============================================================
143 /** Provides export of the row/column label range list of a sheet. */
144 class XclExpLabelranges
: public XclExpRecordBase
, protected XclExpRoot
147 /** Fills the cell range lists with all ranges of the current sheet. */
148 explicit XclExpLabelranges( const XclExpRoot
& rRoot
);
150 /** Writes the LABELRANGES record if it contains at least one range. */
151 virtual void Save( XclExpStream
& rStrm
);
154 /** Fills the specified range list with all label headers of the current sheet.
155 @param rRanges The cell range list to fill.
156 @param xLabelRangesRef The core range list with all ranges.
157 @param nScTab The current Calc sheet index. */
158 void FillRangeList( ScRangeList
& rScRanges
,
159 ScRangePairListRef xLabelRangesRef
, SCTAB nScTab
);
162 ScRangeList maRowRanges
; /// Cell range list for row labels.
163 ScRangeList maColRanges
; /// Cell range list for column labels.
166 // Conditional formatting =====================================================
168 class ScCondFormatEntry
;
171 /** Represents a CF record that contains one condition of a conditional format. */
172 class XclExpCF
: public XclExpRecord
, protected XclExpRoot
175 explicit XclExpCF( const XclExpRoot
& rRoot
, const ScCondFormatEntry
& rFormatEntry
);
179 /** Writes the body of the CF record. */
180 virtual void WriteBody( XclExpStream
& rStrm
);
183 typedef ::std::auto_ptr
< XclExpCFImpl
> XclExpCFImplPtr
;
184 XclExpCFImplPtr mxImpl
;
187 // ----------------------------------------------------------------------------
189 class ScConditionalFormat
;
191 /** Represents a CONDFMT record that contains all conditions of a conditional format.
192 @descr Contains the conditions which are stored in CF records. */
193 class XclExpCondfmt
: public XclExpRecord
, protected XclExpRoot
196 explicit XclExpCondfmt( const XclExpRoot
& rRoot
, const ScConditionalFormat
& rCondFormat
);
197 virtual ~XclExpCondfmt();
199 /** Returns true, if this conditional format contains at least one cell range and CF record. */
200 bool IsValid() const;
202 /** Writes the CONDFMT record with following CF records, if there is valid data. */
203 virtual void Save( XclExpStream
& rStrm
);
204 virtual void SaveXml( XclExpXmlStream
& rStrm
);
207 /** Writes the body of the CONDFMT record. */
208 virtual void WriteBody( XclExpStream
& rStrm
);
211 typedef XclExpRecordList
< XclExpCF
> XclExpCFList
;
213 XclExpCFList maCFList
; /// List of CF records.
214 XclRangeList maXclRanges
; /// Cell ranges for this conditional format.
215 String msSeqRef
; /// OOXML Sequence of References
218 // ----------------------------------------------------------------------------
220 /** Contains all conditional formats of a specific sheet. */
221 class XclExpCondFormatBuffer
: public XclExpRecordBase
, protected XclExpRoot
224 /** Constructs CONDFMT and CF records containing the conditional formats of the current sheet. */
225 explicit XclExpCondFormatBuffer( const XclExpRoot
& rRoot
);
227 /** Writes all contained CONDFMT records with their CF records. */
228 virtual void Save( XclExpStream
& rStrm
);
229 virtual void SaveXml( XclExpXmlStream
& rStrm
);
232 typedef XclExpRecordList
< XclExpCondfmt
> XclExpCondfmtList
;
233 XclExpCondfmtList maCondfmtList
; /// List of CONDFMT records.
236 // Data Validation ============================================================
238 class ScValidationData
;
240 /** Provides export of the data of a DV record.
241 @descr This record contains the settings for a data validation. In detail
242 this is a pointer to the core validation data and a cell range list with all
243 affected cells. The handle index is used to optimize list search algorithm. */
244 class XclExpDV
: public XclExpRecord
, protected XclExpRoot
247 explicit XclExpDV( const XclExpRoot
& rRoot
, ULONG nScHandle
);
250 /** Returns the core handle of the validation data. */
251 inline ULONG
GetScHandle() const { return mnScHandle
; }
253 /** Inserts a new cell range into the cell range list. */
254 void InsertCellRange( const ScRange
& rPos
);
255 /** Converts the Calc range list to the Excel range list.
256 @return false = Resulting range list empty - do not write this record. */
259 virtual void SaveXml( XclExpXmlStream
& rStrm
);
262 /** Writes the body of the DV record. */
263 virtual void WriteBody( XclExpStream
& rStrm
);
266 ScRangeList maScRanges
; /// Calc range list with all affected cells.
267 XclRangeList maXclRanges
; /// Excel range list with all affected cells.
268 XclExpString maPromptTitle
; /// The prompt title.
269 XclExpString maPromptText
; /// The prompt text.
270 XclExpString maErrorTitle
; /// The error title.
271 XclExpString maErrorText
; /// The error text.
272 XclExpStringRef mxString1
; /// String for first condition formula.
273 XclTokenArrayRef mxTokArr1
; /// Formula for first condition.
274 ::rtl::OUString msFormula1
; /// OOXML Formula for first condition.
275 XclTokenArrayRef mxTokArr2
; /// Formula for second condition.
276 ::rtl::OUString msFormula2
; /// OOXML Formula for second condition.
277 sal_uInt32 mnFlags
; /// Miscellaneous flags.
278 ULONG mnScHandle
; /// The core handle for quick list search.
281 // ----------------------------------------------------------------------------
283 /** This class contains the DV record list following the DVAL record. */
284 class XclExpDval
: public XclExpRecord
, protected XclExpRoot
287 explicit XclExpDval( const XclExpRoot
& rRoot
);
288 virtual ~XclExpDval();
290 /** Inserts the cell range into the range list of the DV record with the specified handle. */
291 void InsertCellRange( const ScRange
& rRange
, ULONG nScHandle
);
293 /** Writes the DVAL record and the DV record list. */
294 virtual void Save( XclExpStream
& rStrm
);
295 virtual void SaveXml( XclExpXmlStream
& rStrm
);
298 /** Searches for or creates a XclExpDV record object with the specified handle. */
299 XclExpDV
& SearchOrCreateDv( ULONG nScHandle
);
301 /** Writes the body of the DVAL record. */
302 virtual void WriteBody( XclExpStream
& rStrm
);
305 typedef XclExpRecordList
< XclExpDV
> XclExpDVList
;
306 typedef XclExpDVList::RecordRefType XclExpDVRef
;
308 XclExpDVList maDVList
; /// List of DV records
309 XclExpDVRef mxLastFoundDV
; /// For search optimization.
312 // Web Queries ================================================================
314 /** Contains all records for a web query (linked tables in an HTML document).
315 @descr mode 1 (entire document): mpQryTables==0, mbEntireDoc==true;
316 mode 2 (all tables): mpQryTables==0, mbEntireDoc==false;
317 mode 3 (custom range list): mpQryTables!=0, mbEntireDoc==false. */
318 class XclExpWebQuery
: public XclExpRecordBase
321 /** Constructs a web query record container with settings from Calc. */
322 explicit XclExpWebQuery(
323 const String
& rRangeName
,
325 const String
& rSource
,
326 sal_Int32 nRefrSecs
);
327 virtual ~XclExpWebQuery();
329 /** Writes all needed records for this web query. */
330 virtual void Save( XclExpStream
& rStrm
);
333 XclExpString maDestRange
; /// Destination range.
334 XclExpString maUrl
; /// Source document URL.
335 XclExpStringRef mxQryTables
; /// List of source range names.
336 sal_Int16 mnRefresh
; /// Refresh time in minutes.
337 bool mbEntireDoc
; /// true = entire document.
340 // ----------------------------------------------------------------------------
342 /** Contains all web query records for this document. */
343 class XclExpWebQueryBuffer
: public XclExpRecordList
< XclExpWebQuery
>
346 explicit XclExpWebQueryBuffer( const XclExpRoot
& rRoot
);
349 // ============================================================================