Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_XECONTENT_HXX
30 : : #define SC_XECONTENT_HXX
31 : :
32 : : #include "rangelst.hxx"
33 : : #include "xlcontent.hxx"
34 : : #include "xladdress.hxx"
35 : : #include "xerecord.hxx"
36 : : #include "xeroot.hxx"
37 : : #include "xestring.hxx"
38 : : #include "xeformula.hxx"
39 : : #include "xeextlst.hxx"
40 : :
41 : : #include "colorscale.hxx"
42 : :
43 : : /* ============================================================================
44 : : Classes to export the big Excel document contents (related to several cells or
45 : : globals for the sheet or document).
46 : : - Shared string table
47 : : - Merged cells
48 : : - Hyperlinks
49 : : - Label ranges
50 : : - Conditional formatting
51 : : - Data validation
52 : : - Web Queries
53 : : ============================================================================ */
54 : :
55 : : // Shared string table ========================================================
56 : :
57 : : class XclExpSstImpl;
58 : :
59 : : /** Provides export of the SST (shared string table) record.
60 : : @descr Contains all strings in the document and writes the SST. */
61 : : class XclExpSst : public XclExpRecordBase
62 : : {
63 : : public:
64 : : explicit XclExpSst();
65 : : virtual ~XclExpSst();
66 : :
67 : : /** Inserts a new string into the table.
68 : : @return The index of the string in the SST, used in other records. */
69 : : sal_uInt32 Insert( XclExpStringRef xString );
70 : :
71 : : /** Writes the complete SST and EXTSST records. */
72 : : virtual void Save( XclExpStream& rStrm );
73 : : virtual void SaveXml( XclExpXmlStream& rStrm );
74 : :
75 : : private:
76 : : typedef boost::scoped_ptr< XclExpSstImpl > XclExpSstImplPtr;
77 : : XclExpSstImplPtr mxImpl;
78 : : };
79 : :
80 : : // Merged cells ===============================================================
81 : :
82 : : /** Represents a MERGEDCELLS record containing all merged cell ranges in a sheet. */
83 [ # # ][ # # ]: 0 : class XclExpMergedcells : public XclExpRecordBase, protected XclExpRoot
[ # # ]
84 : : {
85 : : public:
86 : : explicit XclExpMergedcells( const XclExpRoot& rRoot );
87 : :
88 : : /** Appends a new range to the list of merged cell ranges. */
89 : : void AppendRange( const ScRange& rRange, sal_uInt32 nBaseXFId );
90 : : /** Returns the XF identifier of the top-left cell in a merged range. */
91 : : sal_uInt32 GetBaseXFId( const ScAddress& rPos ) const;
92 : :
93 : : /** Writes the record, if it contains at least one merged cell range. */
94 : : virtual void Save( XclExpStream& rStrm );
95 : : virtual void SaveXml( XclExpXmlStream& rStrm );
96 : :
97 : : private:
98 : : ScRangeList maMergedRanges; /// All merged cell ranges of the sheet.
99 : : ScfUInt32Vec maBaseXFIds; /// The XF identifiers of the top-left cells.
100 : : };
101 : :
102 : : // Hyperlinks =================================================================
103 : :
104 : : class SvxURLField;
105 : :
106 : : /** Provides export of hyperlink data. */
107 : : class XclExpHyperlink : public XclExpRecord
108 : : {
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();
114 : :
115 : : /** Returns the cell representation text or 0, if not available. */
116 : 0 : inline const String* GetRepr() const { return mxRepr.get(); }
117 : :
118 : : virtual void SaveXml( XclExpXmlStream& rStrm );
119 : :
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;
128 : :
129 : : /** Writes the body of the HLINK record. */
130 : : virtual void WriteBody( XclExpStream& rStrm );
131 : :
132 : : private:
133 : : typedef boost::scoped_ptr< String > StringPtr;
134 : : typedef boost::scoped_ptr< SvStream > SvStreamPtr;
135 : :
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
142 : : };
143 : :
144 : : typedef XclExpRecordList< XclExpHyperlink > XclExpHyperlinkList;
145 : :
146 : : // Label ranges ===============================================================
147 : :
148 : : /** Provides export of the row/column label range list of a sheet. */
149 [ # # ][ # # ]: 0 : class XclExpLabelranges : public XclExpRecordBase, protected XclExpRoot
[ # # ][ # # ]
150 : : {
151 : : public:
152 : : /** Fills the cell range lists with all ranges of the current sheet. */
153 : : explicit XclExpLabelranges( const XclExpRoot& rRoot );
154 : :
155 : : /** Writes the LABELRANGES record if it contains at least one range. */
156 : : virtual void Save( XclExpStream& rStrm );
157 : :
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 );
165 : :
166 : : private:
167 : : ScRangeList maRowRanges; /// Cell range list for row labels.
168 : : ScRangeList maColRanges; /// Cell range list for column labels.
169 : : };
170 : :
171 : : // Conditional formatting =====================================================
172 : :
173 : : class ScCondFormatEntry;
174 : : class XclExpCFImpl;
175 : :
176 : : /** Represents a CF record that contains one condition of a conditional format. */
177 : : class XclExpCF : public XclExpRecord, protected XclExpRoot
178 : : {
179 : : public:
180 : : explicit XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority );
181 : : virtual ~XclExpCF();
182 : :
183 : : virtual void SaveXml( XclExpXmlStream& rStrm );
184 : :
185 : : private:
186 : : /** Writes the body of the CF record. */
187 : : virtual void WriteBody( XclExpStream& rStrm );
188 : :
189 : : private:
190 : : typedef boost::scoped_ptr< XclExpCFImpl > XclExpCFImplPtr;
191 : : XclExpCFImplPtr mxImpl;
192 : : };
193 : :
194 : : class XclExpCfvo : public XclExpRecord, protected XclExpRoot
195 : : {
196 : : public:
197 : : explicit XclExpCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry& rFormatEntry, const ScAddress& rPos);
198 [ # # ][ # # ]: 0 : virtual ~XclExpCfvo() {}
199 : :
200 : : virtual void SaveXml( XclExpXmlStream& rStrm );
201 : : private:
202 : : const ScColorScaleEntry& mrEntry;
203 : : ScAddress maSrcPos;
204 : : };
205 : :
206 : : class XclExpColScaleCol : public XclExpRecord, protected XclExpRoot
207 : : {
208 : : public:
209 : : explicit XclExpColScaleCol( const XclExpRoot& rRoot, const Color& rColor);
210 : : virtual ~XclExpColScaleCol();
211 : :
212 : : virtual void SaveXml( XclExpXmlStream& rStrm );
213 : : private:
214 : : const Color& mrColor;
215 : : };
216 : :
217 : : // ----------------------------------------------------------------------------
218 : :
219 : : class ScConditionalFormat;
220 : :
221 : : /** Represents a CONDFMT record that contains all conditions of a conditional format.
222 : : @descr Contains the conditions which are stored in CF records. */
223 : : class XclExpCondfmt : public XclExpRecord, protected XclExpRoot
224 : : {
225 : : public:
226 : : explicit XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst );
227 : : virtual ~XclExpCondfmt();
228 : :
229 : : /** Returns true, if this conditional format contains at least one cell range and CF record. */
230 : : bool IsValid() const;
231 : :
232 : : /** Writes the CONDFMT record with following CF records, if there is valid data. */
233 : : virtual void Save( XclExpStream& rStrm );
234 : : virtual void SaveXml( XclExpXmlStream& rStrm );
235 : :
236 : : private:
237 : : /** Writes the body of the CONDFMT record. */
238 : : virtual void WriteBody( XclExpStream& rStrm );
239 : :
240 : : private:
241 : : typedef XclExpRecordList< XclExpRecord > XclExpCFList;
242 : :
243 : : XclExpCFList maCFList; /// List of CF records.
244 : : XclRangeList maXclRanges; /// Cell ranges for this conditional format.
245 : : String msSeqRef; /// OOXML Sequence of References
246 : : };
247 : :
248 [ # # ][ # # ]: 0 : class XclExpColorScale: public XclExpRecord, protected XclExpRoot
[ # # ][ # # ]
249 : : {
250 : : public:
251 : : explicit XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat, sal_Int32 nPriority );
252 : :
253 : : virtual void SaveXml( XclExpXmlStream& rStrm );
254 : : private:
255 : : typedef XclExpRecordList< XclExpCfvo > XclExpCfvoList;
256 : : typedef XclExpRecordList< XclExpColScaleCol > XclExpColScaleColList;
257 : :
258 : : XclExpCfvoList maCfvoList;
259 : : XclExpColScaleColList maColList;
260 : : const ScColorScaleFormat& mrFormat;
261 : : sal_Int32 mnPriority;
262 : : };
263 : :
264 [ # # ][ # # ]: 0 : class XclExpDataBar : public XclExpRecord, protected XclExpRoot
[ # # ][ # # ]
[ # # ]
265 : : {
266 : : public:
267 : : explicit XclExpDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, sal_Int32 nPriority, XclExtLstRef xExtLst );
268 : :
269 : : virtual void SaveXml( XclExpXmlStream& rStrm );
270 : : private:
271 : : boost::scoped_ptr<XclExpCfvo> mpCfvoLowerLimit;
272 : : boost::scoped_ptr<XclExpCfvo> mpCfvoUpperLimit;
273 : : boost::scoped_ptr<XclExpColScaleCol> mpCol;
274 : :
275 : : const ScDataBarFormat& mrFormat;
276 : : sal_Int32 mnPriority;
277 : : };
278 : :
279 : : // ----------------------------------------------------------------------------
280 : :
281 : : /** Contains all conditional formats of a specific sheet. */
282 [ # # ][ # # ]: 0 : class XclExpCondFormatBuffer : public XclExpRecordBase, protected XclExpRoot
[ # # ]
283 : : {
284 : : public:
285 : : /** Constructs CONDFMT and CF records containing the conditional formats of the current sheet. */
286 : : explicit XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtLstRef xExtLst );
287 : :
288 : : /** Writes all contained CONDFMT records with their CF records. */
289 : : virtual void Save( XclExpStream& rStrm );
290 : : virtual void SaveXml( XclExpXmlStream& rStrm );
291 : :
292 : : private:
293 : : typedef XclExpRecordList< XclExpCondfmt > XclExpCondfmtList;
294 : : XclExpCondfmtList maCondfmtList; /// List of CONDFMT records.
295 : : };
296 : :
297 : : // Data Validation ============================================================
298 : :
299 : : /** Provides export of the data of a DV record.
300 : : @descr This record contains the settings for a data validation. In detail
301 : : this is a pointer to the core validation data and a cell range list with all
302 : : affected cells. The handle index is used to optimize list search algorithm. */
303 : : class XclExpDV : public XclExpRecord, protected XclExpRoot
304 : : {
305 : : public:
306 : : explicit XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle );
307 : : virtual ~XclExpDV();
308 : :
309 : : /** Returns the core handle of the validation data. */
310 : 0 : inline sal_uLong GetScHandle() const { return mnScHandle; }
311 : :
312 : : /** Inserts a new cell range into the cell range list. */
313 : : void InsertCellRange( const ScRange& rPos );
314 : : /** Converts the Calc range list to the Excel range list.
315 : : @return false = Resulting range list empty - do not write this record. */
316 : : bool Finalize();
317 : :
318 : : virtual void SaveXml( XclExpXmlStream& rStrm );
319 : :
320 : : private:
321 : : /** Writes the body of the DV record. */
322 : : virtual void WriteBody( XclExpStream& rStrm );
323 : :
324 : : private:
325 : : ScRangeList maScRanges; /// Calc range list with all affected cells.
326 : : XclRangeList maXclRanges; /// Excel range list with all affected cells.
327 : : XclExpString maPromptTitle; /// The prompt title.
328 : : XclExpString maPromptText; /// The prompt text.
329 : : XclExpString maErrorTitle; /// The error title.
330 : : XclExpString maErrorText; /// The error text.
331 : : XclExpStringRef mxString1; /// String for first condition formula.
332 : : XclTokenArrayRef mxTokArr1; /// Formula for first condition.
333 : : ::rtl::OUString msFormula1; /// OOXML Formula for first condition.
334 : : XclTokenArrayRef mxTokArr2; /// Formula for second condition.
335 : : ::rtl::OUString msFormula2; /// OOXML Formula for second condition.
336 : : sal_uInt32 mnFlags; /// Miscellaneous flags.
337 : : sal_uLong mnScHandle; /// The core handle for quick list search.
338 : : };
339 : :
340 : : // ----------------------------------------------------------------------------
341 : :
342 : : /** This class contains the DV record list following the DVAL record. */
343 : : class XclExpDval : public XclExpRecord, protected XclExpRoot
344 : : {
345 : : public:
346 : : explicit XclExpDval( const XclExpRoot& rRoot );
347 : : virtual ~XclExpDval();
348 : :
349 : : /** Inserts the cell range into the range list of the DV record with the specified handle. */
350 : : void InsertCellRange( const ScRange& rRange, sal_uLong nScHandle );
351 : :
352 : : /** Writes the DVAL record and the DV record list. */
353 : : virtual void Save( XclExpStream& rStrm );
354 : : virtual void SaveXml( XclExpXmlStream& rStrm );
355 : :
356 : : private:
357 : : /** Searches for or creates a XclExpDV record object with the specified handle. */
358 : : XclExpDV& SearchOrCreateDv( sal_uLong nScHandle );
359 : :
360 : : /** Writes the body of the DVAL record. */
361 : : virtual void WriteBody( XclExpStream& rStrm );
362 : :
363 : : private:
364 : : typedef XclExpRecordList< XclExpDV > XclExpDVList;
365 : : typedef XclExpDVList::RecordRefType XclExpDVRef;
366 : :
367 : : XclExpDVList maDVList; /// List of DV records
368 : : XclExpDVRef mxLastFoundDV; /// For search optimization.
369 : : };
370 : :
371 : : // Web Queries ================================================================
372 : :
373 : : /** Contains all records for a web query (linked tables in an HTML document).
374 : : @descr mode 1 (entire document): mpQryTables==0, mbEntireDoc==true;
375 : : mode 2 (all tables): mpQryTables==0, mbEntireDoc==false;
376 : : mode 3 (custom range list): mpQryTables!=0, mbEntireDoc==false. */
377 : : class XclExpWebQuery : public XclExpRecordBase
378 : : {
379 : : public:
380 : : /** Constructs a web query record container with settings from Calc. */
381 : : explicit XclExpWebQuery(
382 : : const String& rRangeName,
383 : : const String& rUrl,
384 : : const String& rSource,
385 : : sal_Int32 nRefrSecs );
386 : : virtual ~XclExpWebQuery();
387 : :
388 : : /** Writes all needed records for this web query. */
389 : : virtual void Save( XclExpStream& rStrm );
390 : :
391 : : private:
392 : : XclExpString maDestRange; /// Destination range.
393 : : XclExpString maUrl; /// Source document URL.
394 : : XclExpStringRef mxQryTables; /// List of source range names.
395 : : sal_Int16 mnRefresh; /// Refresh time in minutes.
396 : : bool mbEntireDoc; /// true = entire document.
397 : : };
398 : :
399 : : // ----------------------------------------------------------------------------
400 : :
401 : : /** Contains all web query records for this document. */
402 [ # # ]: 0 : class XclExpWebQueryBuffer : public XclExpRecordList< XclExpWebQuery >
403 : : {
404 : : public:
405 : : explicit XclExpWebQueryBuffer( const XclExpRoot& rRoot );
406 : : };
407 : :
408 : : // ============================================================================
409 : :
410 : : #endif
411 : :
412 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|