fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / inc / xecontent.hxx
blobd986d75fcfa41e93cc45a7eb95ce5a2233369537
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XECONTENT_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XECONTENT_HXX
23 #include "rangelst.hxx"
24 #include "xlcontent.hxx"
25 #include "xladdress.hxx"
26 #include "xerecord.hxx"
27 #include "xeroot.hxx"
28 #include "xestring.hxx"
29 #include "xeformula.hxx"
30 #include "xeextlst.hxx"
32 #include "colorscale.hxx"
34 /* ============================================================================
35 Classes to export the big Excel document contents (related to several cells or
36 globals for the sheet or document).
37 - Shared string table
38 - Merged cells
39 - Hyperlinks
40 - Label ranges
41 - Conditional formatting
42 - Data validation
43 - Web Queries
44 ============================================================================ */
46 // Shared string table ========================================================
48 class XclExpSstImpl;
50 /** Provides export of the SST (shared string table) record.
51 @descr Contains all strings in the document and writes the SST. */
52 class XclExpSst : public XclExpRecordBase
54 public:
55 explicit XclExpSst();
56 virtual ~XclExpSst();
58 /** Inserts a new string into the table.
59 @return The index of the string in the SST, used in other records. */
60 sal_uInt32 Insert( XclExpStringRef xString );
62 /** Writes the complete SST and EXTSST records. */
63 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
64 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
66 private:
67 typedef boost::scoped_ptr< XclExpSstImpl > XclExpSstImplPtr;
68 XclExpSstImplPtr mxImpl;
71 // Merged cells ===============================================================
73 /** Represents a MERGEDCELLS record containing all merged cell ranges in a sheet. */
74 class XclExpMergedcells : public XclExpRecordBase, protected XclExpRoot
76 public:
77 explicit XclExpMergedcells( const XclExpRoot& rRoot );
79 /** Appends a new range to the list of merged cell ranges. */
80 void AppendRange( const ScRange& rRange, sal_uInt32 nBaseXFId );
81 /** Returns the XF identifier of the top-left cell in a merged range. */
82 sal_uInt32 GetBaseXFId( const ScAddress& rPos ) const;
84 /** Writes the record, if it contains at least one merged cell range. */
85 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
86 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
88 private:
89 ScRangeList maMergedRanges; /// All merged cell ranges of the sheet.
90 ScfUInt32Vec maBaseXFIds; /// The XF identifiers of the top-left cells.
93 // Hyperlinks =================================================================
95 class SvxURLField;
97 /** Provides export of hyperlink data. */
98 class XclExpHyperlink : public XclExpRecord
100 public:
101 /** Constructs the HLINK record from an URL text field. */
102 explicit XclExpHyperlink( const XclExpRoot& rRoot,
103 const SvxURLField& rUrlField, const ScAddress& rScPos );
104 virtual ~XclExpHyperlink();
106 /** Returns the cell representation text or 0, if not available. */
107 inline const OUString* GetRepr() const { return m_Repr.isEmpty() ? 0 : &m_Repr; }
109 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
111 void WriteEmbeddedData( XclExpStream& rStrm );
112 void SetDisplay( bool bDisplay ) { mbSetDisplay = bDisplay; }
114 /** Builds file name from the passed file URL. Tries to convert to relative file name.
115 @param rnLevel (out-param) The parent directory level.
116 @param rbRel (out-param) true = path is relative.
117 @param bEncoded if true return an IURI encoded name, not a DOS name. */
118 static OUString BuildFileName(
119 sal_uInt16& rnLevel, bool& rbRel,
120 const OUString& rUrl, const XclExpRoot& rRoot, bool bEncoded );
121 private:
123 /** Writes the body of the HLINK record. */
124 virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
126 private:
127 typedef boost::scoped_ptr< SvStream > SvStreamPtr;
129 ScAddress maScPos; /// Position of the hyperlink.
130 OUString m_Repr; /// Cell representation text.
131 SvStreamPtr mxVarData; /// Buffer stream with variable data.
132 sal_uInt32 mnFlags; /// Option flags.
133 XclExpStringRef mxTextMark; /// Location within m_Repr
134 OUString msTarget; /// Target URL
135 bool mbSetDisplay; /// True if display attribute it written
138 typedef XclExpRecordList< XclExpHyperlink > XclExpHyperlinkList;
140 // Label ranges ===============================================================
142 /** Provides export of the row/column label range list of a sheet. */
143 class XclExpLabelranges : public XclExpRecordBase, protected XclExpRoot
145 public:
146 /** Fills the cell range lists with all ranges of the current sheet. */
147 explicit XclExpLabelranges( const XclExpRoot& rRoot );
149 /** Writes the LABELRANGES record if it contains at least one range. */
150 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
152 private:
153 /** Fills the specified range list with all label headers of the current sheet.
154 @param rRanges The cell range list to fill.
155 @param xLabelRangesRef The core range list with all ranges.
156 @param nScTab The current Calc sheet index. */
157 static void FillRangeList( ScRangeList& rScRanges,
158 ScRangePairListRef xLabelRangesRef, SCTAB nScTab );
160 private:
161 ScRangeList maRowRanges; /// Cell range list for row labels.
162 ScRangeList maColRanges; /// Cell range list for column labels.
165 // Conditional formatting =====================================================
167 class ScCondFormatEntry;
168 class XclExpCFImpl;
170 /** Represents a CF record that contains one condition of a conditional format. */
171 class XclExpCF : public XclExpRecord, protected XclExpRoot
173 public:
174 explicit XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority );
175 virtual ~XclExpCF();
177 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
179 private:
180 /** Writes the body of the CF record. */
181 virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
183 private:
184 typedef boost::scoped_ptr< XclExpCFImpl > XclExpCFImplPtr;
185 XclExpCFImplPtr mxImpl;
188 class XclExpDateFormat : public XclExpRecord, protected XclExpRoot
190 public:
191 explicit XclExpDateFormat( const XclExpRoot& rRoot, const ScCondDateFormatEntry& rFormatEntry, sal_Int32 nPriority );
192 virtual ~XclExpDateFormat();
194 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
196 private:
197 const ScCondDateFormatEntry& mrFormatEntry;
198 sal_Int32 mnPriority;
201 class XclExpCfvo : public XclExpRecord, protected XclExpRoot
203 public:
204 explicit XclExpCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry& rFormatEntry, const ScAddress& rPos, bool bFirst = true);
205 virtual ~XclExpCfvo() {}
207 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
208 private:
209 const ScColorScaleEntry& mrEntry;
210 ScAddress maSrcPos;
211 bool mbFirst;
214 class XclExpColScaleCol : public XclExpRecord, protected XclExpRoot
216 public:
217 explicit XclExpColScaleCol( const XclExpRoot& rRoot, const Color& rColor);
218 virtual ~XclExpColScaleCol();
220 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
221 private:
222 const Color& mrColor;
225 class ScConditionalFormat;
227 /** Represents a CONDFMT record that contains all conditions of a conditional format.
228 @descr Contains the conditions which are stored in CF records. */
229 class XclExpCondfmt : public XclExpRecord, protected XclExpRoot
231 public:
232 explicit XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst, sal_Int32& rIndex );
233 virtual ~XclExpCondfmt();
235 /** Returns true, if this conditional format contains at least one cell range and CF record. */
236 bool IsValid() const;
238 /** Writes the CONDFMT record with following CF records, if there is valid data. */
239 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
240 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
242 private:
243 /** Writes the body of the CONDFMT record. */
244 virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
246 private:
247 typedef XclExpRecordList< XclExpRecord > XclExpCFList;
249 XclExpCFList maCFList; /// List of CF records.
250 XclRangeList maXclRanges; /// Cell ranges for this conditional format.
251 OUString msSeqRef; /// OOXML Sequence of References
254 class XclExpColorScale: public XclExpRecord, protected XclExpRoot
256 public:
257 explicit XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat, sal_Int32 nPriority );
259 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
260 private:
261 typedef XclExpRecordList< XclExpCfvo > XclExpCfvoList;
262 typedef XclExpRecordList< XclExpColScaleCol > XclExpColScaleColList;
264 XclExpCfvoList maCfvoList;
265 XclExpColScaleColList maColList;
266 sal_Int32 mnPriority;
269 class XclExpDataBar : public XclExpRecord, protected XclExpRoot
271 public:
272 explicit XclExpDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, sal_Int32 nPriority, const OString& rGUID);
274 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
275 private:
276 boost::scoped_ptr<XclExpCfvo> mpCfvoLowerLimit;
277 boost::scoped_ptr<XclExpCfvo> mpCfvoUpperLimit;
278 boost::scoped_ptr<XclExpColScaleCol> mpCol;
280 const ScDataBarFormat& mrFormat;
281 sal_Int32 mnPriority;
282 OString maGUID;
285 class XclExpIconSet : public XclExpRecord, protected XclExpRoot
287 public:
288 explicit XclExpIconSet( const XclExpRoot& rRoot, const ScIconSetFormat& rFormat, sal_Int32 nPriority );
290 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
291 private:
292 typedef XclExpRecordList< XclExpCfvo > XclExpCfvoList;
294 XclExpCfvoList maCfvoList;
295 const ScIconSetFormat& mrFormat;
296 sal_Int32 mnPriority;
299 /** Contains all conditional formats of a specific sheet. */
300 class XclExpCondFormatBuffer : public XclExpRecordBase, protected XclExpRoot
302 public:
303 /** Constructs CONDFMT and CF records containing the conditional formats of the current sheet. */
304 explicit XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtLstRef xExtLst );
306 /** Writes all contained CONDFMT records with their CF records. */
307 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
308 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
310 private:
311 typedef XclExpRecordList< XclExpCondfmt > XclExpCondfmtList;
312 XclExpCondfmtList maCondfmtList; /// List of CONDFMT records.
315 // Data Validation ============================================================
317 /** Provides export of the data of a DV record.
318 @descr This record contains the settings for a data validation. In detail
319 this is a pointer to the core validation data and a cell range list with all
320 affected cells. The handle index is used to optimize list search algorithm. */
321 class XclExpDV : public XclExpRecord, protected XclExpRoot
323 public:
324 explicit XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle );
325 virtual ~XclExpDV();
327 /** Returns the core handle of the validation data. */
328 inline sal_uLong GetScHandle() const { return mnScHandle; }
330 /** Inserts a new cell range into the cell range list. */
331 void InsertCellRange( const ScRange& rPos );
332 /** Converts the Calc range list to the Excel range list.
333 @return false = Resulting range list empty - do not write this record. */
334 bool Finalize();
336 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
338 private:
339 /** Writes the body of the DV record. */
340 virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
342 private:
343 ScRangeList maScRanges; /// Calc range list with all affected cells.
344 XclRangeList maXclRanges; /// Excel range list with all affected cells.
345 XclExpString maPromptTitle; /// The prompt title.
346 XclExpString maPromptText; /// The prompt text.
347 XclExpString maErrorTitle; /// The error title.
348 XclExpString maErrorText; /// The error text.
349 XclExpStringRef mxString1; /// String for first condition formula.
350 XclTokenArrayRef mxTokArr1; /// Formula for first condition.
351 OUString msFormula1; /// OOXML Formula for first condition.
352 XclTokenArrayRef mxTokArr2; /// Formula for second condition.
353 OUString msFormula2; /// OOXML Formula for second condition.
354 sal_uInt32 mnFlags; /// Miscellaneous flags.
355 sal_uLong mnScHandle; /// The core handle for quick list search.
358 /** This class contains the DV record list following the DVAL record. */
359 class XclExpDval : public XclExpRecord, protected XclExpRoot
361 public:
362 explicit XclExpDval( const XclExpRoot& rRoot );
363 virtual ~XclExpDval();
365 /** Inserts the cell range into the range list of the DV record with the specified handle. */
366 void InsertCellRange( const ScRange& rRange, sal_uLong nScHandle );
368 /** Writes the DVAL record and the DV record list. */
369 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
370 virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
372 private:
373 /** Searches for or creates a XclExpDV record object with the specified handle. */
374 XclExpDV& SearchOrCreateDv( sal_uLong nScHandle );
376 /** Writes the body of the DVAL record. */
377 virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
379 private:
380 typedef XclExpRecordList< XclExpDV > XclExpDVList;
381 typedef XclExpDVList::RecordRefType XclExpDVRef;
383 XclExpDVList maDVList; /// List of DV records
384 XclExpDVRef mxLastFoundDV; /// For search optimization.
387 // Web Queries ================================================================
389 /** Contains all records for a web query (linked tables in an HTML document).
390 @descr mode 1 (entire document): mpQryTables==0, mbEntireDoc==true;
391 mode 2 (all tables): mpQryTables==0, mbEntireDoc==false;
392 mode 3 (custom range list): mpQryTables!=0, mbEntireDoc==false. */
393 class XclExpWebQuery : public XclExpRecordBase
395 public:
396 /** Constructs a web query record container with settings from Calc. */
397 explicit XclExpWebQuery(
398 const OUString& rRangeName,
399 const OUString& rUrl,
400 const OUString& rSource,
401 sal_Int32 nRefrSecs );
402 virtual ~XclExpWebQuery();
404 /** Writes all needed records for this web query. */
405 virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
407 private:
408 XclExpString maDestRange; /// Destination range.
409 XclExpString maUrl; /// Source document URL.
410 XclExpStringRef mxQryTables; /// List of source range names.
411 sal_Int16 mnRefresh; /// Refresh time in minutes.
412 bool mbEntireDoc; /// true = entire document.
415 /** Contains all web query records for this document. */
416 class XclExpWebQueryBuffer : public XclExpRecordList< XclExpWebQuery >
418 public:
419 explicit XclExpWebQueryBuffer( const XclExpRoot& rRoot );
422 #endif
424 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */